Guard role grant emission behind WillSyncResourceType - #33
Conversation
Gates cross-type role-grant emission from the user syncer on the customer's sync filter, so grants aren't emitted for a resource type the sync excludes. The user builder clones the user resource type and annotates it SkipEntitlements, or SkipEntitlementsAndGrants when role is filtered out -- users have no entitlements of their own and their only grants are the cross-type role grants, so the whole pass can be skipped. The flag is named skipRoleResourceType and stored inverted so the zero value means "sync everything". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
| if rt.GetId() != resourceTypeUser.GetId() { | ||
| continue | ||
| } | ||
| if hasGuardAnno(rt, &v2.SkipEntitlementsAndGrants{}) { | ||
| t.Fatal("zero-value Connector advertised SkipEntitlementsAndGrants") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // RoleResourceTypeID is what the sync filter is queried with; it must match the |
There was a problem hiding this comment.
🟡 Suggestion: this test passes vacuously if the user syncer ever disappears from ResourceSyncers — the loop continues on every non-user type and then asserts nothing. Consider tracking a found bool and failing with t.Fatal("user syncer not registered") when it stays false, so the guard can't silently stop testing anything.
Connector PR Review: Guard role grant emission behind WillSyncResourceTypeBlocking Issues: 0 | Suggestions: 2 | Threads Resolved: 0 Review SummaryScanned the full PR diff (5 files, no Security IssuesNone found. Correctness IssuesNone found. Suggestions
Prompt for AI agents |
Gates cross-type grant emission from the user syncer on the customer's sync
filter, so grants aren't emitted for a resource type the sync excludes.
Reference: ConductorOne/baton-linear#55.
userResourceType.Grants()emits the role grants (read from each admin user'sroleNamein the pass it already makes, rather than re-scanning every user onceper role -- which is why
resourceTypeRolealready carriesSkipGrants). Whenrole is excluded from the sync those grants would point at an unsynced type, so
newUserBuilderclones the user resource type and annotates itSkipEntitlementsAndGrantsand the SDK skips the pass entirely. Users have noentitlements of their own, so the unfiltered case is annotated
SkipEntitlements.The flag is named
skipRoleResourceTypeand stored inverted so the zero valuemeans "sync everything".
baton_capabilities.jsonis regenerated: the user type now advertisesSkipEntitlementsin the unfiltered capability set.Build, tests, and golangci-lint (0 issues) pass.
Supersedes #31, which used a
syncRolesflag instead of theskip<Type>ResourceTypeconvention.