Skip to content

fix: preserve service errors before cache hooks have a value - #81

Open
Shubham-Padkonde wants to merge 1 commit into
aws:masterfrom
Shubham-Padkonde:fix/preserve-initial-cache-error
Open

Shubham-Padkonde wants to merge 1 commit into
aws:masterfrom
Shubham-Padkonde:fix/preserve-initial-cache-error

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown

Description

Why is this change being made?

When the first DescribeSecret or GetSecretValue request fails, a configured cache hook still receives an uninitialized None value. A hook that decodes or looks up its stored object can raise its own exception, hiding the original Secrets Manager error.

What is changing?

Use a private sentinel for an unpopulated cache and return no result without invoking the hook in that case. The existing error propagation and retry backoff then preserve the service exception. A successful hook result of None or 0 remains valid, including when a later refresh fails and the cache serves its previous value.

Related Links

Fixes #20.

Testing

  • Both DescribeSecret and GetSecretValue regressions failed with KeyError: None before the fix and now expose ResourceNotFoundException on initial and cached-error reads.
  • Full unit suite: 48 passed, four subtests passed, 99.28% coverage (100% in cache/items.py), Python 3.12 on Linux.
  • Flake8 on changed files, Ruff 0.15.22, and repository Pylint checks pass.
  • Live AWS integration tests were not run; service responses and errors use botocore Stubber with dummy credentials.

Reviewee Checklist

  • Changes reviewed and tested
  • Description and testing sections completed
  • Unit tests and coverage check pass
  • Live integration tests pass locally (not run; no live AWS resources used)
  • Regression tests cover the affected cache-hook path
  • No secret logging or sensitive data added
  • Sentinel rationale is documented in code
  • No public API or documentation change needed
  • No intended breaking changes

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Shubham-Padkonde
Shubham-Padkonde requested a review from a team as a code owner October 4, 2026 12:33

This branch has not been deployed

No deployments
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.

Don't wrap ResourceNotFoundException

1 participant