You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
environment_opts_out() fails open for a falsy non-string value (0, False) in an explicit mapping #46
environment_opts_out() documents that "a value that is not a string -- opts out too", and the 0.5.0 release made every opt-out fail closed. A falsy non-string value in an explicit mapping still fails open, because (env.get(name) or "") turns it into a blank (unset) variable:
A truthy non-string (1, True) does opt out, since .strip() raises and the except returns True. That is the only case test_an_environment_that_cannot_be_read_disables_and_does_not_raise covers ({"DO_NOT_TRACK": 1}).
os.environ only ever holds strings, so the constructor's own check is not affected. The bug only shows up for a program that passes its own mapping (for example, settings parsed from YAML or TOML, where TRACE_USAGE_REPORTING: 0 becomes an int).
Suggested fix: treat only a missing (None) value as unset, and make any other non-string value opt out, as the docstring already says. String handling is unchanged, so no wire format, accepted value or disabled_reason changes, and trace-client-java (whose environment map is Map<String, String>) is unaffected.
Activity
Make a falsy non-string environment value opt out (#46) (#47)