Skip to content

fix: always read fresh credentials from disk on every request#294

Open
anasstahr wants to merge 2 commits into
mainfrom
fix/always-read-fresh-credentials
Open

fix: always read fresh credentials from disk on every request#294
anasstahr wants to merge 2 commits into
mainfrom
fix/always-read-fresh-credentials

Conversation

@anasstahr
Copy link
Copy Markdown
Contributor

Summary

Changes

Remove credential session caching from SessionHolder so that every request reads fresh credentials from disk. Previously, the proxy cached a boto3.Session and only refreshed it reactively after receiving a 401/403 error. Now, SessionHolder.get_session() always creates a new session, ensuring account switches and credential refreshes on disk take effect immediately.

  • Replaced mark_needs_refresh() / refresh_if_needed() with a single get_session() method that always returns a fresh session
  • Removed reactive 401/403 refresh logic from _handle_error_response (no longer needed)
  • Simplified create_transport_with_sigv4 — no longer creates an initial session at startup

User experience

Before: If you switched AWS accounts or refreshed credentials on disk while the proxy was running, the proxy continued using the old cached credentials until they expired and triggered a 401/403. This could result in requests being signed with the wrong account's credentials.

After: Every request reads the current credentials from disk. Switching accounts or refreshing credentials takes effect on the very next request — no 401 roundtrip needed.

Checklist

  • I have reviewed the contributing guidelines
  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented

Is this a breaking change? (Y/N)

  • Yes
  • No

Please add details about how this change was tested.

  • Did integration tests succeed?
  • If the feature is a new use case, is it necessary to add a new integration test case?

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@anasstahr anasstahr requested a review from a team as a code owner May 27, 2026 10:37
@anasstahr anasstahr requested review from bidesh and zdwheels May 27, 2026 10:37
@@ -112,34 +112,20 @@ def create_aws_session(profile: Optional[str] = None) -> boto3.Session:


class SessionHolder:
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.

Does this class still make sense?

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.

2 participants