Skip to content

fix: Keep org-specific token rotation isolated#555

Draft
stray-nick wants to merge 3 commits intoMeltanoLabs:mainfrom
stray-nick:fix-org-specific-token-rotation-v1264
Draft

fix: Keep org-specific token rotation isolated#555
stray-nick wants to merge 3 commits intoMeltanoLabs:mainfrom
stray-nick:fix-org-specific-token-rotation-v1264

Conversation

@stray-nick
Copy link
Copy Markdown

@stray-nick stray-nick commented Apr 25, 2026

Summary

Keep token rotation scoped to the current organization when that organization has its own configured token pool.

GitHub App installation tokens are org-scoped. If a stream is reading private repositories for one org and get_next_auth_token() falls through to another org's installation token, GitHub can return misleading 404 Not Found responses for repositories that do exist and are accessible with the correct org token.

What changed

  • get_next_auth_token() now prefers the current organization's token managers when current_organization has a configured token pool.
  • Fallback to org-agnostic or other-org tokens is still allowed when the current organization has no configured token pool.
  • Added regression tests for both paths:
    • org-specific token rotation stays inside the current org's pool.
    • missing org-specific pools still use the existing fallback behavior.

Validation

uv run pytest tests/test_authenticator.py
# 44 passed

@stray-nick stray-nick marked this pull request as ready for review April 25, 2026 12:03
@stray-nick stray-nick requested a review from a team as a code owner April 25, 2026 12:03
@stray-nick stray-nick changed the title fix: keep org-specific token rotation isolated fix: Keep org-specific token rotation isolated Apr 25, 2026
@stray-nick stray-nick marked this pull request as draft April 25, 2026 13:31
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.

1 participant