Skip to content

fix: env2bool matches truthy values exactly - #11081

Open
aryansk wants to merge 1 commit into
treeverse:mainfrom
aryansk:fix-env2bool-exact-match
Open

fix: env2bool matches truthy values exactly#11081
aryansk wants to merge 1 commit into
treeverse:mainfrom
aryansk:fix-env2bool-exact-match

Conversation

@aryansk

@aryansk aryansk commented Aug 16, 2026

Copy link
Copy Markdown

Fixes #11080.

What

dvc.utils.env2bool decided truthiness with an unanchored re.search("1|y|yes|true", ...), so any env value that merely contained 1, y, yes or true was treated as true — e.g. my_path, anything, only, v1.0, yep.

Why

env2bool is used for DVC_EXP_AUTO_PUSH, DVC_IGNORE_ISATTY, DVC_SQLALCHEMY_ECHO and DVC_TEST, so unrelated values silently flip behavior on. The truthy values were always intended to be exactly 1 / y / yes / true.

How

Match the exact truthy values (case-insensitively) instead of a substring search:

return var.lower() in {"1", "y", "yes", "true"}

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/utils and the env2bool-adjacent suites (test_progress, test_analytics, test_updater) pass; ruff check + format clean.

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.
@github-project-automation github-project-automation Bot moved this to Backlog in DVC Aug 16, 2026
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.98%. Comparing base (2431ec6) to head (ff1732e).
⚠️ Report is 213 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

env2bool matches its truthy pattern as a substring, so unrelated values read as true

2 participants