Repository navigation
Make a falsy non-string environment value opt out - #47
Merged
Merged
Conversation
environment_opts_out() read each variable as `(env.get(name) or "")`, so a 0, False or [] in an explicit mapping counted as unset and left reporting on, while the string "0" opted out. Only a missing (None) value now counts as unset; any other non-string opts out, as the docstring already promised. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Self-review rubric (the review was performed inline during a Gardener session, https://github.com/Stephenson-Software/gardener):
Observation for the owner: drafted by Claude on behalf of Daniel Stephenson |
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.
Summary
environment_opts_out()read each variable as(env.get(name) or ""), so a falsy non-string value in an explicit mapping (0,False,[]) was treated as unset and left reporting on. The string"0"already opted out. The docstring has always said that "a value that is not a string -- opts out too"._variable()helper treats only a missing (None) value as unset. Any other non-string value raises, which the existingexceptturns into an opt-out. String handling is byte-for-byte unchanged.environment_opts_outdocstring now says explicitly that this covers0andFalse.os.environonly ever holds strings, so the constructor's own check behaves exactly as before. Only a program that passes its own mapping (for example, settings parsed from YAML or TOML) is affected, and for that program the switch now fails closed.Closes #46
Test plan
test_a_value_that_is_not_a_string_opts_out_even_when_it_is_emptycovers0,False,[],0.0,b"",1andTruefor both variables, and checks thatNonestill counts as unset.python3 -m unittestpasses locally on Python 3.8.10: 86 tests, OK.trace-client-java
No change is needed in Java. Its environment map is
Map<String, String>, so a non-string value cannot reach it. The accepted values, thedisabled_reasonstrings and the wire format are unchanged, and the version is not bumped.Deferred
MAX_TAGS) stays open. It is still blocked on an owner decision about the README promise thattags"always holds at leastversion", and on a coordinated change in trace-client-java.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
🤖 Generated with Claude Code
drafted by Claude on behalf of Daniel Stephenson