Skip to content

fix: match boolean environment values exactly - #11093

Closed
lprnmns wants to merge 1 commit into
treeverse:mainfrom
lprnmns:fix/env2bool-exact-values
Closed

lprnmns wants to merge 1 commit into
treeverse:mainfrom
lprnmns:fix/env2bool-exact-values

Conversation

@lprnmns

@lprnmns lprnmns commented Sep 2, 2026

Copy link
Copy Markdown

Problem

env2bool uses an unanchored regex search, so unrelated values containing y or 1, such as my_branch and v1.0, enable DVC environment flags. Only complete recognized affirmative tokens should evaluate to true.

Fixes #11080.

Fix

Normalize surrounding whitespace and case, then compare against the existing affirmative vocabulary: 1, y, yes, and true. Unset-variable behavior and recognized values are unchanged.

Tests

  • uv run pytest tests/unit/utils/test_utils.py::test_env2bool_matches_the_entire_value -q — 9 passed
  • uv run pytest tests/unit/utils/test_utils.py -q — 43 passed, 1 skipped (Windows-specific)
  • uvx ruff check dvc/utils/__init__.py tests/unit/utils/test_utils.py — passed
  • uvx ruff format --check dvc/utils/__init__.py tests/unit/utils/test_utils.py — passed
  • git diff --check — passed
  • ❗ I have followed the Contributing to DVC checklist.

  • 📖 This focused behavior fix does not require a documentation update.

Thank you for the contribution - we'll try to review it as soon as possible. 🙏

@github-project-automation github-project-automation Bot moved this to Backlog in DVC Sep 2, 2026
@CLAassistant

CLAassistant commented Sep 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Sep 2, 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 (cf8d009).
⚠️ Report is 213 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11093      +/-   ##
==========================================
+ Coverage   90.68%   90.98%   +0.30%     
==========================================
  Files         504      505       +1     
  Lines       39795    41142    +1347     
  Branches     3141     3263     +122     
==========================================
+ Hits        36087    37432    +1345     
- 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.

@lprnmns

lprnmns commented Sep 4, 2026

Copy link
Copy Markdown
Author

Closing this because the same env2bool exact-match fix is already being worked on in #11081 and #11082. Sorry for the duplicate.

@lprnmns lprnmns closed this Sep 4, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in DVC Sep 4, 2026
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