Skip to content

Only emit user grants (where we emit the role grants) if role resource type is enabled #55

Merged
laurenleach merged 3 commits into
mainfrom
lauren/check-sync-role-for-grants
Jul 14, 2026
Merged

Only emit user grants (where we emit the role grants) if role resource type is enabled #55
laurenleach merged 3 commits into
mainfrom
lauren/check-sync-role-for-grants

Conversation

@laurenleach

Copy link
Copy Markdown
Contributor

Only emit user grants (where we emit the role grants) if role resource type is enabled

@laurenleach
laurenleach requested a review from a team July 14, 2026 21:55
Comment thread pkg/connector/user.go
Comment on lines +246 to 252
func userBuilder(client *linear.Client, skipRoleGrants bool) *userResourceType {
if skipRoleGrants {
resourceTypeUser.Annotations = annotations.New(&v2.SkipEntitlementsAndGrants{})
} else {
resourceTypeUser.Annotations = annotations.New(&v2.SkipEntitlements{})
}
return &userResourceType{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: userBuilder mutates the package-level global resourceTypeUser.Annotations as a side effect. This is functionally correct for the single-connector-per-process usage here, but it makes the resource type's annotations depend on construction order and would be surprising if the connector were ever instantiated twice in-process with different skipRoleGrants values (last write wins). Consider assigning the annotations to a per-builder copy of the resource type instead of the shared global. (confidence: medium)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a big deal if it runs ever in C1, but in a lambda it is specific to the connector id. I might copy the resource type just because it feels less problematic instead of changing the global package variable imo, even thought it doesn't really matter.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Connector PR Review: Only emit user grants (where we emit the role grants) if role resource type is enabled

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base 6688dd5b4b33.
Review mode: incremental since 7815aa3c
View review run

Review Summary

The new commit only regenerated metadata: baton_capabilities.json now advertises SkipEntitlements on the User type, and docs/connector.mdx was regenerated (Accounts provision checkmark plus auto-generated markers). Both artifacts are consistent with the already-reviewed code change in pkg/connector — the zero-value capabilities stub (skipRoleGrants=false) resolves to SkipEntitlements, and account provisioning already exists. The full PR diff was scanned for security and correctness; no new issues were found. The previously raised suggestion about userBuilder mutating the package-global resourceTypeUser.Annotations (pkg/connector/user.go:246-252) still stands but is unchanged and already reported, so it is not repeated here.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

@btipling btipling self-assigned this Jul 14, 2026

@btipling btipling left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When connectors ran in C1 modifying the global resource variable caused an incident so I have a PTSD comment, but it doesn't actually impact running in a lambda

Comment thread pkg/connector/user.go
Comment on lines +246 to 252
func userBuilder(client *linear.Client, skipRoleGrants bool) *userResourceType {
if skipRoleGrants {
resourceTypeUser.Annotations = annotations.New(&v2.SkipEntitlementsAndGrants{})
} else {
resourceTypeUser.Annotations = annotations.New(&v2.SkipEntitlements{})
}
return &userResourceType{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a big deal if it runs ever in C1, but in a lambda it is specific to the connector id. I might copy the resource type just because it feels less problematic instead of changing the global package variable imo, even thought it doesn't really matter.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

t.Fatalf("failed to create client: %v", err)
}
return userBuilder(client)
return userBuilder(client, false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: The core behavior of this PR — userBuilder emitting SkipEntitlements vs SkipEntitlementsAndGrants based on skipRoleGrants — has no direct test. Consider a small table-driven test asserting ResourceType().GetAnnotations() contains the expected annotation for each value of skipRoleGrants, so a future refactor doesn't silently drop the grant-skipping behavior. (confidence: medium)

@github-actions

Copy link
Copy Markdown
Contributor

Connector PR Review: Only emit user grants (where we emit the role grants) if role resource type is enabled

Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0
Criteria: loaded .claude/skills/ci-review.md from trusted base 6688dd5b4b33
Review mode: full
View review run

Review Summary

The full PR diff was scanned for security and correctness. This change wires the SDK's cli.RunTimeOpts.SyncResourceTypeIDs through DefineConfigurationV2 so the user syncer only emits role-membership grants when the role resource type is in the sync filter (or no filter is set); when roles are excluded, the cloned user resource type carries SkipEntitlementsAndGrants instead of SkipEntitlements, avoiding grants that target un-synced role resources. All SDK APIs used (DefineConfigurationV2, GetConnectorFunc2, ConnectorOpts.WillSyncResourceType, SkipEntitlements/SkipEntitlementsAndGrants) verify against the vendored SDK, the WillSyncResourceType "default to all" semantics match the inline comments, and all callers of the changed userBuilder/New signatures were updated. No dependency manifest changes. No blocking issues found.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

  • pkg/connector/user_test.go:32 — no direct test asserts the SkipEntitlements vs SkipEntitlementsAndGrants annotation selection based on skipRoleGrants, which is the core behavior of this PR.
Prompt for AI agents
Verify each finding against the current code and only fix it if needed.

## Suggestions

In `pkg/connector/user_test.go`:
- Around line 32: The PR's core behavior is that userBuilder(client, skipRoleGrants)
  clones resourceTypeUser and attaches SkipEntitlements when skipRoleGrants is false
  and SkipEntitlementsAndGrants when true. Add a table-driven test that calls
  userBuilder with each boolean value, then inspects
  builder.ResourceType(ctx).GetAnnotations() to assert the expected annotation type is
  present in each case, so the grant-skipping behavior can't be silently dropped by a
  future refactor.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

@laurenleach
laurenleach merged commit 43204cf into main Jul 14, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants