Repository navigation
Land incremental sync (CXP-897) and follow-up fixes on main - #97
Conversation
* feat: incremental sync v1 - scoped implementation * feat: extend incremental sync to role/permission-assignment changes Add audit log action mappings for account-admin, workspace-access, and SQL-access role changes, plus a coarser fallback for the cluster-create and instance-pool-create entitlements. mapAuditRowToResource now returns multiple affected resources per audit row so a single action can refresh both a principal and the role(s) it holds. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: add event_id tiebreaker to audit log pagination ORDER BY event_time ASC alone gives no deterministic ordering among rows sharing an event_time, so paging via a >= start_time filter plus a remembered ID set can stall forever if a single event_time has >= auditLogPageLimit rows. Order by (event_time, event_id) and page with a composite (event_time, event_id) > predicate instead, so the cursor always advances regardless of how many rows share a timestamp. * fix: bound sql statement polling and cancel on give-up pollStatement could block for as long as the caller's context allowed if a warehouse got stuck PENDING/RUNNING (cold start, queued, quota), hanging Validate() indefinitely when incremental sync is enabled. Cap polling at statementPollMaxWait and cancel the statement via DELETE when giving up so it stops occupying the warehouse. * fix: nil-safe parent access in user/service-principal/role Get The SDK's GetResource passes request.GetParentResourceId() straight through to Get, which is nil whenever C1 has no parent recorded for the resource (e.g. workspace-token auth, where userResource deliberately omits WithParentResourceID). That nil parent was then dereferenced directly in userResource, servicePrincipalResource, and roleResource, panicking on resync after a RESOURCE_CHANGE event. Use the nil-safe GetResourceType()/GetResource() getters instead, matching the pattern groups.go already used. * fix: mirror token-auth branch in workspaceBuilder.Get Get always called GetWorkspace, which hits the Account API via ListWorkspaces. The Account API is unreachable under workspace-token auth, so any targeted sync of a workspace (advertised via CAPABILITY_TARGETED_SYNC) always failed in that mode, even though List already builds a minimalWorkspaceResource from the configured workspace list to avoid the same call. Get now mirrors that branch. * fix: select audit event parent by Account API availability mapAuditRowToResource picked the user/group/service-principal parent from whether the audit row carried a workspace_id, not from how the resource is actually synced. Users/groups/service principals are only ever synced under the account when the Account API is reachable (accountResource declares them as children only then; groupGrantParent already encodes this rule), so a workspace-scoped row in that mode built an ID that was never synced (e.g. workspace/<deployment>/group/x instead of account/<id>/group/x), and the real resource never got refreshed. Select the parent from IsAccountAPIAvailable() instead, matching groupGrantParent. Also thread the real ctx through instead of context.Background(), now that groupResourceId's ctx parameter is actually used for something worth passing correctly. * fix: don't require the Account API for incremental sync under token auth Validate() and ListEvents() both called ListWorkspaces unconditionally to resolve the audit-log query workspace, but the Account API is unreachable under workspace-token auth — so incremental sync always failed Validate() and every ListEvents poll for token-auth customers. Add resolveSQLWorkspaces, which builds minimal workspaces from the configured deployment names under token auth (mirroring workspaceBuilder.List's token-auth branch) instead of calling ListWorkspaces, and use it in both places. auditEventFeed now carries the configured workspace list to support this. Workspace-scoped audit rows can't be resolved to a deployment name under token auth this way (no numeric workspace ID is ever learned), so they're skipped by mapAuditRowToResource rather than mis-resolved — a known limitation, not a regression, since incremental sync couldn't run under token auth at all before this. * refactor: simplify quotedInClause and ExecuteStatement's status check quotedInClause hand-rolled a strings.Join; use it directly. The two-case switch in ExecuteStatement (success vs everything else) reads clearer as a plain if. Cosmetic only, per review feedback. * feat: add sql-warehouse-workspace to pin the audit-log query workspace sqlQueryWorkspace picked whichever workspace sorted alphabetically first by deployment name to run the system.access.audit query, with no way to route it to the workspace that actually hosts sql-warehouse-id. SQL warehouses only exist in one workspace, so querying through the wrong one 404s — this broke deterministically for any account with more than one workspace, unless the warehouse happened to live in the alphabetically-smallest one. Add --sql-warehouse-workspace to pin the deployment name explicitly, validated against the resolved workspace list in both Validate() and ListEvents() via a shared resolveQueryWorkspace helper. When unset and more than one workspace is available, log a Debug line naming the arbitrarily-picked workspace and pointing at the new flag, so it's diagnosable without escalating to Warn/Error for what is, until set, a config gap rather than a connector fault. Regenerated config_schema.json and pkg/config/conf.gen.go; updated README's incremental sync section and flag list. * fix: address remaining audit-log review findings - Use RFC3339Nano for start_time so the (event_time, event_id) tiebreaker keeps sub-second precision, fixing duplicate re-emission at page boundaries. - Reject enable-incremental-sync under workspace token auth at Validate(), since no audit row can ever resolve to a synced resource that way and it would otherwise poll forever for nothing. - Add the three incremental-sync config fields to both field groups so they're selectable in the UI; regenerate config_schema.json. - Propagate rate-limit info from the SQL Statement Execution API through ExecuteStatement into ListEvents' annotations. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: log corrupt event cursors instead of resetting silently decodeEventCursor now logs at Debug when a cursor fails to decode, so the watermark reset is observable instead of invisible. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * chore: promote Debug logs to Warn for visibility * chore: retrigger GitHub jobs * fix: drop incremental-sync fields from the workspace-token config group Validate() rejects enable-incremental-sync under token auth, so offering those fields in the workspace-token group let the UI present an option that can never succeed. Remove them from that group (they stay in oauth2) and regenerate config_schema.json; note the OAuth-only requirement in the README. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: address remaining audit-log review findings (round 2) - Filter resolveSQLWorkspaces through --workspaces on the OAuth2 path, and mirror the same allowlist check in workspaceBuilder.Get. - Clamp intra-page cursor advances to the trailing-lag boundary so a full page of recent rows can't permanently defeat auditLogTrailingLag. - Trust an explicit earliestEvent watermark instead of clamping it to the 1h lookback default. - Bound Validate()'s audit-log probe with a dedicated timeout. - Validate parsed audit-log rows have enough columns before indexing. - Cancel timed-out SQL statements via POST .../cancel instead of DELETE, which only closes an already-terminal statement. - Note the OAuth2-only requirement for incremental sync in the docs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: address remaining audit-log review findings (round 3) - Key the audit action-name map by (service_name, action_name) instead of action_name alone, since action_name is ambiguous across services (e.g. "delete" also means cluster termination). Fixes the map along the way: adds addPrincipalsToGroup/removePrincipalsFromGroup, renames deleteGroup -> removeGroup and createUser/deleteUser -> add/delete, and stops attaching the account-admin role to removeAdmin (which actually revokes workspace admin). - Drop the write-only LatestEventSeen cursor field. - Detect a stale-but-valid cursor (older than system.access.audit's 365-day retention) and self-heal it like a corrupt one; keep routine corrupt/missing-cursor logging at Debug and log genuine staleness at Warn. - Skip and log an individual malformed audit-log row instead of failing the whole page. - Add regression coverage: a >page-limit tied-timestamp burst, an end-to-end mocked ListEvents run (also covering the service_name filter and rate-limit propagation), and a skip-malformed-row test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: infer the SQL warehouse's workspace instead of requiring it in config sql-warehouse-workspace forced operators to manually pin the workspace hosting the configured SQL warehouse, and was unenforced for the multi-workspace case it existed to cover (see the resolveQueryWorkspace Debug-log-and-guess fallback this replaces). Databricks has no account-level "which workspace owns this warehouse" API, but each workspace's SQL warehouse endpoint is queryable directly, so the connector now probes each candidate workspace for the configured sql-warehouse-id and caches the match instead of asking for it up front. - Add Client.WarehouseExists to probe a single workspace for a warehouse ID, distinguishing 404 from a real error. - Replace resolveQueryWorkspace's pin-or-guess logic with resolveWarehouseWorkspace, which skips probing entirely for a single workspace and otherwise probes until one workspace confirms the warehouse; the resolved workspace is cached per auditEventFeed instance so it's found once, not on every poll. - Remove the sql-warehouse-workspace config field, its config_schema.json entry, and its README documentation/CLI help text. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: stop fetching group members needlessly in groupBuilder.Get Get is only used to rebuild the resource, which needs id/displayName/ parent, not membership — Grants already fetches members separately when building membership grants. Matches List, which already fetches without members. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * chore: clean up and comments * feat: emit CREATE_GRANT/CREATE_REVOKE for group membership audit events Group membership actions (addPrincipalToGroup, removePrincipalFromGroup, and their plural batch variants) are atomic, unambiguous grant/revoke events per Databricks' own audit log docs: the group is the entitlement's resource, targetUserId is the principal, and add/remove gives the direction. Emitting CREATE_GRANT/CREATE_REVOKE for these lets C1 apply the grant directly instead of waiting on a targeted resync. Other assignment-shaped actions (setAdmin/removeAdmin, the roleNames-driven update* actions, ACL-change actions) stay RESOURCE_CHANGE: their scope or direction isn't fully determinable from the audit row alone, and guessing would risk writing an incorrect grant straight into C1's data model. EventFeedMetadata now advertises all three event types. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: bound the audit log query by lag instead of clamping the cursor advanceEventCursor tried to enforce auditLogTrailingLag by overwriting the cursor with a synthetic now-lag timestamp after the fact, which caused three bugs: it could jump StartAt backwards past where paging already was (no floor against the incoming cursor), it wiped the (event_time, event_id) tiebreaker whenever it fired (re-emitting the whole trailing window every poll), and hasMore was computed from the post-parse row count so one malformed row on a full page caused premature draining. Bound the query itself by lag_cutoff (event_time <= :lag_cutoff) instead. Every row queryAuditLog can return is now already within the lag window, so the cursor only ever advances to a real row's boundary (hasMore) or jumps straight to lag_cutoff once drained (proven empty beyond it) - no synthetic timestamp, no clamp, no floor needed. hasMore now uses the raw statement row count. Also guards against querying an inverted range when the cursor is already past lag_cutoff (current gap: auditLogLookback < auditLogTrailingLag on bootstrap). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: remaining audit-log review findings (bootstrap lookback, log levels, exclude check) - auditLogLookback now equals auditLogTrailingLag instead of a narrower 1h default, so a fresh install's first poll isn't immediately past lagCutoff (which would otherwise skip every query until it caught up). - Downgrade the 4 remaining skip-and-continue logs from Warn to Debug (stale cursor, malformed row, statement poll timeout, cancel failure) - these are graceful degradation, not connector bugs, and Warn surfaces as a C1 incident. - workspaceBuilder.Get's token-auth branch now also checks IsWorkspaceNameExcluded, mirroring List, so a workspace in both --workspaces and --databricks-exclude-workspaces is rejected consistently by both methods. - Comment out createServicePrincipal/updateServicePrincipal/ deleteServicePrincipal and setAccountAdmin/removeAccountAdmin in auditLogActions: none of these are real action_name values per the official Databricks audit log reference (verified against the AWS, GCP, and Azure docs mirrors) - setAdmin already covers account-admin grants, and the only documented service-principal action is changeServicePrincipalAcls. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: address PR comments * fix: resolve group-membership grant principal type dynamically principalType was hardcoded to userResourceType for the four addPrincipalToGroup/removePrincipalFromGroup (singular and plural) grant mappings, but request_params.targetUserId can also be a nested group or a service principal - the audit log has no field to tell which. A wrong guess silently fails C1's grant lookup rather than corrupting data, but the connector already knows how to sync all three principal types, so it's worth resolving properly. Add resolvePrincipalType: probes GetUser, then GetGroup, then GetServicePrincipal (in that order, stopping at the first match) using the same 404-detection idiom as the existing WarehouseExists probe. A real (non-404) API error propagates up and is logged/skipped per-row rather than aborting the whole poll; rate-limit info is still recorded even on a skipped row. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: stop advanceEventCursor stall and mistranslated nested-group principal id advanceEventCursor's panic fix regressed into a stall: when hasMore is true but only the last raw row fails to parse, lastRawBoundary is zero, and the old fallback returned the cursor unchanged while ListEvents still reported HasMore true - the SDK would re-issue the identical query forever, even though the other rows on that page parsed fine. Fall back to the last successfully parsed row first, and only stop claiming HasMore when neither source can advance. Also log (instead of discarding) parseEventBoundary's error on the raw last-row extraction, so a stuck cursor is diagnosable. Separately, a grant-mapped principal that resolves to a nested group was emitted with its raw native id instead of the composite id (account/workspace + group) every other group resource in this connector uses - apply the same groupResourceId transform Grants() uses for nested-group members, so the principal actually matches what was synced. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * chore: fix lint errors * feat: enable incremental sync via sql-warehouse-id, drop enable-incremental-sync Incremental sync is now on exactly when sql-warehouse-id is set (whitespace counts as unset) and off when it is empty, removing the separate enable-incremental-sync flag. - config: remove EnableIncrementalSyncField; sql-warehouse-id description leads with the on/off rule; regenerate conf.gen.go and config_schema.json - Validate: no ID skips all incremental-sync checks; a set ID fails validation if no workspace is in sync scope, the warehouse can't be located, or system.access.audit can't be queried. Logs whether incremental sync is enabled - audit feed: gated on sqlWarehouseID instead of the removed bool - README and connector.mdx: document the new behavior, drop the flag - tests for disabled/enabled validation paths and the no-op feed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: address audit feed review comments (retention, rate limits, gRPC codes) - lower auditLogRetention to 30 days; C1 doesn't request event-feed data older than that - propagate rate limit data from ListWorkspaces in ListEvents, from GetWorkspace in workspaceBuilder.Get, from the Validate incremental-sync checks, and on error paths of the user/group/service principal Get methods - add gRPC status codes to connector-inferred errors: NotFound for missing warehouse/workspace, FailedPrecondition for no workspace in scope and failed statements, Aborted for canceled/closed statements, DeadlineExceeded for statement poll timeout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: bypass GET cache for statement polling and incremental-sync refreshes - add databricks.WithoutCache(ctx); doRequest sends GETs made with it with Cache-Control: no-cache so the uhttp response cache is skipped - pollStatement polls with it: the poll URL never changes, so a cached PENDING/RUNNING response froze polling until statementPollMaxWait - user/group/service principal/workspace Get (RESOURCE_CHANGE refreshes) use it so re-syncs return fresh data; regular sync callers of the same client methods stay cached - resolveWarehouseWorkspace skips workspaces that return 401/403 instead of aborting, so a service principal not assigned to every workspace can still locate the warehouse; the not-found error names skipped workspaces - tests for poll-past-cache, cache scoping, and inaccessible workspaces Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: retry audit rows whose principal lookup fails instead of skipping them A transient principal lookup failure (429, 5xx, transport) was logged at Debug and the row skipped, so the cursor advanced past it and the grant/revoke was lost until the next full sync. ListEvents now returns the error before encoding the cursor, so the next poll retries the page. Also clarify in docs/connector.mdx that removed group memberships are picked up incrementally; only deletions wait for the next full sync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: map account-admin, user activation and workspace assignment audit events Per the official audit log reference (AWS/Azure/GCP): - setAccountAdmin/removeAccountAdmin are real `accounts` actions; map them to the account-admin role (previously commented out as nonexistent). - setAdmin is workspace admin (it pairs with removeAdmin in the workspace-level table), so it no longer refreshes the account-admin role. - Map activateUser/deactivateUser to a user refresh. - Map `workspace` add/update/deletePermissionAssignment to a workspace refresh, resolving the workspace from request_params when the row's workspace_id is 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: satisfy nilerr in workspace_id request param parsing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: address audit feed review suggestions - Only fail the poll on retryable principal lookup errors; skip rows whose lookup fails permanently (sampled Warn) so the cursor can't get stuck. - Refresh the group when a membership row's principal can't be resolved instead of dropping the row. - Keep refreshing the account-admin role on setAdmin. - Resolve account-level updatePermissionAssignment rows' workspace from request_params. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: drop unreachable workspace-parent fallback from audit feed The account API is always available (OAuth is the only auth method and Validate fails without it), so principals are always account-parented. Remove the accountAPIAvailable parameter, the workspace-parent fallback, and the workspace-scoped principal lookup, along with the tests that covered the impossible token-auth state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: cover ListEvents full-page cursor advance and !advanced wiring Add a ListEvents-level test for a full audit log page: it pages forward from the last raw row's boundary, and when no boundary parses it reports HasMore=false with the cursor unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: stop incremental sync checks from blocking connector validation Validate no longer checks workspace scope, the SQL warehouse, or system.access.audit access when sql-warehouse-id is set. Incremental sync is optional, so a misconfiguration should not block full syncs or provisioning; the event feed already reports these problems as errors on each poll. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: document incremental sync requirements and service principal admin role Spell out what incremental sync needs (Unity Catalog, system tables, grants, warehouse access), the single-region limit of system.access.audit, and the serverless warehouse recommendation. State that the service principal needs the Account admin role, and fix the account-level Account admin wording. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: explain SQL statement timeouts and cancel statements on every timeout When a statement doesn't finish within the poll limit, include why: the query was still running, or for a pending statement, the warehouse's state (stopped, starting, or running but at capacity). A deadline that expires mid-poll is now treated as a timeout too, so the statement is canceled instead of left running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: state the same-region requirement in the sql-warehouse-id description system.access.audit only exposes workspace-level events for the warehouse's cloud region, so the warehouse can't be in just any workspace. Update the field description, its comment, the regenerated config schema and the README help output to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf: cache principal type lookups within each ListEvents call resolvePrincipalType tried user, group, then service principal for every grant-mapped row, and the HTTP cache only keeps 200s, so a principal named on many rows repeated its 404 lookups each time. Memoize the resolved type (including no match) per ListEvents call; errors are not cached. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: use a tagged switch on statement state (staticcheck QF1002) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: fix lint * test: add a local test server for the incremental sync event feed Adds test-server/, a stdlib-only stand-in for the Databricks APIs that Validate and the audit-log event feed call: OAuth M2M, workspaces, account SCIM lookups, SQL warehouses and the Statement Execution API. It serves TLS with a generated CA, routes account and workspace hosts by Host header, and recognizes the connector's system.access.audit query over seeded audit rows. Each behavior is labeled DOC, ASSUMPTION or DECISION in code and README. Adds a CI job that runs the event feed against it, diffs the events with testdata/expected-events.jsonl and checks the timeout message for a warehouse that never starts. It needs no secrets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: add debug logs to trace the incremental sync event feed Log each step of ListEvents (poll window, workspaces in scope, warehouse workspace resolution, audit query, row-to-event mapping) and a per-poll summary with audit row and event counts by type. Log SQL statement submission, success and result chunks with row counts, warehouse lookups, principal type resolution, and the targeted Get refreshes. Every message names the function that logged it; all are at Debug level. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit e0e3320)
…88) * docs: align incremental sync coverage, timeout and warehouse notes with the code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: tighten incremental sync scope, timeout and warehouse wording Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 03655ad)
…eGroup (#92) * fix(databricks): refresh every workspace entitlement role on updateUser/updateGroup Workspace SCIM entitlement changes are logged only as accounts/updateUser or updateGroup, with no ACL row and no detail about which entitlement changed. The feed refreshed only allow-cluster-create and allow-instance-pool-create for those actions, so databricks-sql-access and workspace-access changes waited for the next full sync. Refresh all four workspace entitlement roles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * improvements Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(databricks): drop duplicate resource changes within an event feed page Each workspace updateUser/updateGroup row refreshes all four entitlement roles, and every role refresh pages through all principals in the workspace. ListEvents now keeps only the last resource change per resource within a page, so the surviving event carries the newest row's ID and time. Grant and revoke events are never collapsed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 617283f)
…ycle audit events (#89) * fix(databricks): resolve service principals in principal-lifecycle audit events Databricks logs service principal lifecycle and admin changes under the user action names with targetUserId. Resolve the principal type at map time so the audit feed emits service_principal changes instead of user ones, falling back to user when the principal no longer exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(databricks): propagate principal-lookup rate limits from audit rows Return the rate limit from resolvePrincipalType on success, skip empty rate-limit descriptions so they don't overwrite the audit query's, and drop a redundant grant check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(databricks): leave principal deletions to full sync Drop the accounts/delete audit mapping: a deleted principal can't be fetched, so emitting a resource change only spent lookups that 404 and asked C1 to refresh a resource that is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(databricks): fix expected test-server events after dropping accounts/delete The delete row no longer emits an event, so the user's remaining change comes from the deactivateUser row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 0a8ab12)
…nges in the audit feed (#93) * Emit a membership event per member for batched group changes in the audit feed addPrincipalsToGroup/removePrincipalsFromGroup rows list every member in targetUserId, comma-separated. The feed looked that value up as one principal, got a 405 and dropped the row. Split the list and emit a grant or revoke per member, refresh the group when a member can't be resolved or a lookup fails permanently, and cap per-row lookups. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Cover the live multi-member audit row shape in the event feed tests Replays the request_params shape Databricks logged for batched SCIM PATCHes: comma-separated targetUserId with targetUserName listing the names in the same order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Bound member lookups per poll and keep resolved members on lookup failures A non-retryable lookup error on one member now skips that member and refreshes the group instead of dropping the row's other grants, so buildAffectedGrants only returns retryable errors. Membership lookups share a per-poll budget, since Account SCIM GETs are rate limited. The lookup-failure counter is renamed to match what it counts, and the SCIM test handler is shared. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 017ba10)
Superseded — see the current review report for commit
|
| AND (event_time > :start_time OR (event_time = :start_time AND event_id > :start_after_event_id)) | ||
| AND event_time <= :lag_cutoff | ||
| AND service_name IN (%s) | ||
| AND action_name IN (%s) |
There was a problem hiding this comment.
🟠 Bug: The query never filters on response.status_code, but system.access.audit also logs requests that failed (403, 400, 404). So a rejected addPrincipalToGroup or removePrincipalFromGroup still goes through buildAffectedGrants and is emitted as a real CreateGrantEvent/CreateRevokeEvent, which stays wrong in C1 until the next full sync. Add AND response.status_code = 200 to the WHERE clause, at least for the grant-mapped actions, and add a test-server row for a failed call. (Confidence: high)
|
|
||
| func isRetryableLookupError(err error) bool { | ||
| switch status.Code(err) { | ||
| case codes.Unavailable, codes.ResourceExhausted, codes.DeadlineExceeded, codes.Internal, codes.Unknown, codes.Canceled: |
There was a problem hiding this comment.
🟡 Suggestion: status.Code returns codes.Unknown for any error that has no gRPC status. That includes the url.PathUnescape/url.Parse errors in doRequestWithOptions (request.go:235-243) when the principal id comes from an audit row, and also JSON decode failures. Those errors are deterministic, but because Unknown counts as retryable here, ListEvents returns the error without advancing the cursor, and every later poll fails on the same row, so the feed stalls. Consider dropping codes.Unknown (and probably Internal) from the retryable set, or giving client-side parse errors a non-retryable code. (Confidence: medium)
| Columns []struct { | ||
| Name string `json:"name"` | ||
| } `json:"columns"` | ||
| } `json:"schema"` |
There was a problem hiding this comment.
🟡 Suggestion: manifest.truncated is never read. If an INLINE result hits the size cap (about 25 MiB, which is possible with large request_params), the page comes back with fewer than auditLogPageLimit rows. ListEvents then reads that as a drained page and moves the cursor to lagCutoff, so the rows that were cut off are skipped for good. Parse truncated and either return an error or page from the last row returned. (Confidence: medium)
Superseded — see the current review report for commit
|
There was a problem hiding this comment.
Blocking issues found — see the full review report
system.access.audit also logs requests Databricks rejected, so a failed addPrincipalToGroup or removePrincipalFromGroup (e.g. a 403) was emitted as a real grant or revoke and stayed wrong in C1 until the next full sync. Filter the audit query on response.status_code = 200. The test server now applies the same predicate and seeds a failed removePrincipalFromGroup row that must produce no event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Superseded — see the current review report for commit
|
| AND event_time <= :lag_cutoff | ||
| AND service_name IN (%s) | ||
| AND action_name IN (%s) | ||
| AND response.status_code = 200 |
There was a problem hiding this comment.
🟡 Suggestion: = 200 drops every successful row whose status isn't exactly 200. That includes a 201/204 from SCIM create/delete-style calls and any row with a NULL response.status_code. Those changes would then never reach C1 until the next full sync. Unless Databricks is known to always log 200 for these actions, response.status_code BETWEEN 200 AND 299 excludes the rejected requests just as well, without that risk. Confidence: low.
Connector PR Review: Land incremental sync (CXP-897) and follow-up fixes on mainBlocking Issues: 0 | Suggestions: 3 | Threads Resolved: 0 Review SummaryThe new commit adds Security IssuesNone found. Correctness IssuesNone found. Suggestions
Resolved prior findings
Prompt for AI agentsReviewed commit: |
There was a problem hiding this comment.
No blocking issues found — see the full review report
Superseded by a completed review with no blocking issues; current audit evidence persisted in CI.
main added sql-warehouse-id (#97) while this branch added the auth field groups, so both touched the same var block in pkg/config/config.go and the import block in pkg/connector/connector.go. Both sides are kept. sql-warehouse-id joins commonFields: it applies whichever way the connector authenticates, and a field that is in no group is exported in no method's schema, so incremental sync would otherwise be unreachable from the hosted form. config_schema.json is regenerated with ./connector config. Build, vet, test and lint are clean. A full sync against the tenant matches both parents exactly: 12 resource types, 326 resources, 282 entitlements, 759 grants, 0 connector errors. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Summary
Brings the incremental sync feature and its follow-up fixes from
stagingtomain, without the other work currently onstaging.Each PR's squash commit was cherry-picked onto
mainwithgit cherry-pick -x, in merge order:Not included (still only on
staging): #70 (Unity Catalog foundation / metastore) and #81 (CXP-1251, group member grant pagination).Conflict resolution
Only config files conflicted. No Go code needed changes.
.github/workflows/ci.yaml(CXP-897 Incremental sync support #56): kept both sides.main's account enable/disable lifecycle test steps stay, and the newtest-serverjob is added.baton_capabilities.json(CXP-897 Incremental sync support #56): kept both sides.CAPABILITY_ACTIONSfrommainsits next toCAPABILITY_TARGETED_SYNC,CAPABILITY_EVENT_FEED_V2andCAPABILITY_SERVICE_MODE_TARGETED_SYNC. Checked that it matches the output ofbaton-databricks capabilities.go.mod([CXP-1295] - Emit service principals, not users, from principal-lifecycle audit events #89): keptmain's newer dependency versions (baton-sdk v0.46.0; staging is on v0.42.5). Movedgithub.com/google/uuidfrom indirect to direct, as [CXP-1295] - Emit service principals, not users, from principal-lifecycle audit events #89 did.Verification
go build ./...andgo vet ./...are clean.go test ./... -count=1passes.go mod tidyandgo mod vendorproduce no changes.test-server/). The events matchtest-server/testdata/expected-events.jsonl.Note for reviewers
These PRs were written and reviewed against baton-sdk v0.42.5 (staging). On
mainthey run on v0.46.0. They build and the tests pass, but a real sync against a Databricks tenant is recommended before release.🤖 Generated with Claude Code