fix(claude-admin): after_id cursor pagination + rate-limit backoff fallback - #1955
Conversation
|
📝 WalkthroughWalkthroughThe Claude Admin connector increases 429 retry capacity, applies exponential fallback backoff, migrates four streams from offset to ChangesClaude Admin connector updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/ingestion/connectors/ai/claude-admin/connector.yaml`:
- Line 839: Update the claude_admin_invites stream configuration to map the
Admin API’s invited_at field into the schema’s created_at field, while
preserving the existing tenant_id_injection transformation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 4050be55-34ac-4383-aef3-8b8a14327468
📥 Commits
Reviewing files that changed from the base of the PR and between 65e7b44 and 6cbf76a9ff788964a7770e31ca04ba207793bea2.
📒 Files selected for processing (2)
src/ingestion/connectors/ai/claude-admin/connector.yamlsrc/ingestion/connectors/ai/claude-admin/descriptor.yaml
6cbf76a to
bbb4755
Compare
…sor pagination Anthropic Admin API list endpoints paginate via after_id/has_more cursors only; they do not support offset/limit. The claude_admin_api_keys, claude_admin_workspaces, claude_admin_workspace_members (parent substream), and claude_admin_invites streams used an OffsetIncrement paginator, which never terminates against this API: unrecognized offset params are ignored server-side, so pages never shrink below page_size and the connector loops indefinitely. Confirmed on a live sync stuck 65h+ re-reading the same api_keys page. Switched all four to the after_id_paginator already used correctly by claude_admin_users. Also bumps descriptor.yaml (the prior value has a leading zero and is silently rejected by reconcile's classify_bump strict-semver-ish validation, meaning version bumps to this connector were never actually being republished). Fixes #1953 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Signed-off-by: Dmitry Saukh <38005371+cyberdima@users.noreply.github.com>
…m restart loop Anthropic's 429 responses on these endpoints carry no Retry-After header, so the RATE_LIMITED error handler's WaitTimeFromHeader strategy always resolves to no wait time and the CDK falls back to its own short, bounded internal backoff (~5 tries, well under a minute). Once that's exhausted mid-pagination the read aborts with no resumable checkpoint, so a full-refresh stream restarts from page 1. For a large multi-page stream (api_keys, ~80 pages at limit=1000) any single 429 during the walk turns into a full re-read, and under sustained rate pressure this repeats indefinitely — observed directly during verification of the #1953 fix. Adds ExponentialBackoffStrategy as a fallback backoff strategy (used whenever WaitTimeFromHeader returns None) and raises max_retries so the connector actually waits out a real rate-limit window instead of giving up almost immediately. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Signed-off-by: Dmitry Saukh <38005371+cyberdima@users.noreply.github.com>
bbb4755 to
38afb36
Compare
Admin API returns invited_at for invite timestamps, but the schema exposes created_at (project-wide convention) with no transformation backing it, so consumers got null/absent created_at. Addresses CodeRabbit review comment on PR #1955. Signed-off-by: Dmitry Saukh <38005371+cyberdima@users.noreply.github.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/ingestion/connectors/ai/claude-admin/connector.yaml (1)
23-48: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAdd a regression test for 429s without
Retry-After.The visible reliability helper always supplies
Retry-After: 0, so it only exercises the header-based path. Add a 429-without-header case that recovers successfully; this verifies the new fallback and the target CDK’s strategy chaining.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/ingestion/connectors/ai/claude-admin/connector.yaml` around lines 23 - 48, Add a regression test using the visible reliability helper or equivalent fixture to return HTTP 429 without a Retry-After header, then verify the connector recovers successfully through the ExponentialBackoffStrategy fallback configured alongside WaitTimeFromHeader. Keep the existing header-based 429 coverage and assert the previously failing request eventually completes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/ingestion/connectors/ai/claude-admin/connector.yaml`:
- Around line 23-48: Add a regression test using the visible reliability helper
or equivalent fixture to return HTTP 429 without a Retry-After header, then
verify the connector recovers successfully through the
ExponentialBackoffStrategy fallback configured alongside WaitTimeFromHeader.
Keep the existing header-based 429 coverage and assert the previously failing
request eventually completes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6f6d0823-370e-4c47-b914-e2ac619d6fd6
📥 Commits
Reviewing files that changed from the base of the PR and between 6cbf76a9ff788964a7770e31ca04ba207793bea2 and 428a2d4.
📒 Files selected for processing (2)
src/ingestion/connectors/ai/claude-admin/connector.yamlsrc/ingestion/connectors/ai/claude-admin/descriptor.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
- src/ingestion/connectors/ai/claude-admin/descriptor.yaml
Summary
claude_admin_api_keys,claude_admin_workspaces,claude_admin_workspace_members(parent substream), andclaude_admin_invitesused an offset/limit (OffsetIncrement) paginator against Anthropic Admin API endpoints that only supportafter_id/has_morecursor pagination. Sinceoffsetis ignored server-side, pages never shrink belowpage_sizeand the paginator never terminates. Confirmed on a live sync stuck 65h+ re-reading the sameapi_keyspage. Switched all four to theafter_id_paginatoralready used correctly byclaude_admin_users. Fixes claude-admin connector: offset-based pagination never terminates on Anthropic Admin API list endpoints #1953.descriptor.yamlto strict semver (ADR-0015) — the prior date-string value (2026.07.25) has a leading zero and is silently rejected by reconcile'sclassify_bumpvalidation, so version bumps to this connector were never actually being republished to Airbyte.Retry-Afterheader, soWaitTimeFromHeaderalways resolves to no wait time and the CDK falls back to a short bounded internal backoff. Once exhausted mid-pagination, the read aborts with no resumable checkpoint and a full-refresh stream restarts from page 1 — forapi_keys(~80 pages), any single 429 during the walk causes a full re-read, which repeats indefinitely under sustained rate pressure. Found this while verifying the pagination fix on staging. AddedExponentialBackoffStrategyas a fallback and raisedmax_retries.Test plan
ManifestDeclarativeSourceinstantiates cleanly against the pinned CDK 6.60.16 harnessclaude-adminconnector test suite passes (13 passed)api_keys) cancelled, manifest republished, fresh sync completed all 8 streams without the infinite loop recurring🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
created_atfrominvited_atwhen needed.Performance
after_idpagination for API keys, workspaces, workspace members, and invites.Chores