Skip to content

Add a short-lived cache for non-recoverable errors - #4781

Open
ysaito1001 wants to merge 1 commit into
ysaito/consistent-credentials-refreshfrom
non-recoverable-error-cache
Open

Add a short-lived cache for non-recoverable errors#4781
ysaito1001 wants to merge 1 commit into
ysaito/consistent-credentials-refreshfrom
non-recoverable-error-cache

Conversation

@ysaito1001

@ysaito1001 ysaito1001 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Motivation and Context

This PR follows #4774 in the series to support consistent credentials refresh across credential providers. It brings StaticStabilityCache in line with a later revision of the design, which protects a credentials source even in the event of non-recoverable errors.

These PRs merge into the ysaito/consistent-credentials-refresh feature branch.

Description

Non-recoverable refresh errors intentionally skip the refresh backoff so actionable errors (e.g. "reauthenticate") surface immediately. But that means an application that catches such an error and retries in a loop would call the credential source (e.g. STS) on every retry. To protect the source, the SDK must briefly cache the error and re-raise it to subsequent callers without re-contacting the source.

This PR adds a short-lived, jittered cache for non-recoverable errors to StaticStabilityCache, separate from the existing refresh backoff. It adds no public API and changes no client default behavior on its own.

Specifically, on a non-recoverable refresh failure, the cache stores the error with an expiry of now + uniform_random(1s..=5s) and still raises it to the current caller. While that window is live, subsequent resolutions re-raise the cached error without contacting the source — the gate is checked after acquiring the single-flight refresh lock, before any source call. A successful refresh clears the cached error.

Testing

  • Re-vendored the modeled scenarios in aws-runtime/test-data/credential-refresh-tests.json to match the revised design
  • Added manual tests for behaviors the sequential JSON runner cannot express:
    • mandatory_concurrent_non_recoverable_reuses_cached_error — concurrent callers on an expired credential: one performs the refresh and fails non-recoverably; the others reuse the cached error, so the source is contacted exactly once.
    • jittered_error_cache_bounds — the cache window always falls in 1..=5s, the invariant the
      deterministic suite relies on.

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

@github-actions

This comment was marked as outdated.

1 similar comment
@github-actions

Copy link
Copy Markdown

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@ysaito1001
ysaito1001 marked this pull request as ready for review August 13, 2026 16:00
@ysaito1001
ysaito1001 requested a review from a team as a code owner August 13, 2026 16:00
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