Repository navigation
fix(idempotency): treat empty or unparsable POWERTOOLS_IDEMPOTENCY_DISABLED as not disabled - #8734
Open
lechakrawarthy wants to merge 1 commit into
Open
lechakrawarthy wants to merge 1 commit into
lechakrawarthy wants to merge 1 commit into
Conversation
…SABLED as not disabled
strtobool("") raised ValueError, so an empty or non-boolean value crashed
every invocation before the handler ran. Resolve the variable once in a
helper that returns False (with a debug log) for values strtobool rejects,
and use it in both idempotent and idempotent_function.
lechakrawarthy
force-pushed
the
fix/idempotency-disabled-env
branch
from
November 1, 2026 10:27
308f637 to
364b675
Compare
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue number:
closes #8728
Summary
Changes
idempotentandidempotent_functionboth calledstrtobool(os.getenv("POWERTOOLS_IDEMPOTENCY_DISABLED", "false")), andstrtoboolraisesValueErrorfor an empty string or any non-boolean value, so every invocation crashed before the handler ran._is_idempotency_disabled()inidempotency.py. It resolves the variable once and returnsFalsefor valuesstrtoboolrejects, with a debug log saying the value was ignored. Recognised values behave exactly as before.resolve_truthy_env_var_choicefromshared/functions.py: it calls the samestrtobooland raises the same way, and changing it would change behaviour for every utility that uses it.Tests
Added
test_idempotency_disabled_envvar_empty_or_unparsableintests/functional/idempotency/_boto3/test_idempotency.py, next to the existing env var tests. It runs both decorators with""," ","maybe"and the variable unset, and checks the functions return their result and the persistence layer is still called (idempotency stays on). The existing truthy and falsy cases are unchanged and still pass.Verification
Ran locally on Windows (
uv sync --locked --extra all --extra redis --extra datamasking; thevalkeyextra does not build on Windows).New test on
develop, before the fix:With the fix:
After that run I split the debug log string over two lines (ruff E501) and re-ran the env var tests, ruff and mypy:
AI disclosure
This change was made with the help of an AI coding assistant. I ran the commands above and the output is pasted as seen.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.