fix: env2bool matches truthy values exactly - #11081
Open
aryansk wants to merge 1 commit into
Open
Conversation
env2bool used an unanchored regex search, so any value containing 1, y, yes or true (e.g. 'my_path', 'v1.0') was treated as true. Match the exact truthy values instead, fixing treeverse#11080.
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11081 +/- ##
==========================================
+ Coverage 90.68% 90.98% +0.30%
==========================================
Files 504 505 +1
Lines 39795 41146 +1351
Branches 3141 3263 +122
==========================================
+ Hits 36087 37436 +1349
- Misses 3042 3071 +29
+ Partials 666 639 -27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fixes #11080.
What
dvc.utils.env2booldecided truthiness with an unanchoredre.search("1|y|yes|true", ...), so any env value that merely contained1,y,yesortruewas treated as true — e.g.my_path,anything,only,v1.0,yep.Why
env2boolis used forDVC_EXP_AUTO_PUSH,DVC_IGNORE_ISATTY,DVC_SQLALCHEMY_ECHOandDVC_TEST, so unrelated values silently flip behavior on. The truthy values were always intended to be exactly1/y/yes/true.How
Match the exact truthy values (case-insensitively) instead of a substring search:
Tests
Parametrized regression test covering the intended truthy/falsy values plus the false positives above; all fail on
main, pass with the fix.tests/unit/utilsand the env2bool-adjacent suites (test_progress,test_analytics,test_updater) pass; ruff check + format clean.