Skip to content

Fix check_writeable_path to validate the target folder itself - #14065

Open
Sanjays2402 wants to merge 1 commit into
equinor:mainfrom
Sanjays2402:fix/writeable-path-checks-target-folder
Open

Fix check_writeable_path to validate the target folder itself#14065
Sanjays2402 wants to merge 1 commit into
equinor:mainfrom
Sanjays2402:fix/writeable-path-checks-target-folder

Conversation

@Sanjays2402

Copy link
Copy Markdown

Issue
Resolves #14056

Approach
check_writeable_path walks up from the configured path to the lowest existing directory, but the loop only stopped on a directory that was already writeable. An existing but unwritable simulation_folder therefore did not terminate the walk — it kept climbing to a writeable ancestor and validation passed, so the error only surfaced when every directory on the path was unwritable.

The walk now stops at the first existing directory and the os.access check after the loop decides whether to raise. A writeable folder still passes, a non-existent path still falls back to its nearest existing ancestor, and an existing unwritable folder now raises the intended ValueError.

This also un-xfails test_that_simulation_folder_without_write_access_raises_validation_error, the placeholder added in #14055 for exactly this bug; it fails on main and passes with the fix.

  • PR title captures the intent of the changes, and is fitting for release notes.
  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.
  • Make sure unit tests pass locally after every commit (git rebase -i main --exec 'just rapid-tests')

When applicable

  • When screenshots are changed: Review screenshot-PR in ert-testdata,
    merge screenshot-PR in ert-testdata before merging this PR.
  • When there are user facing changes: Updated documentation
  • New behavior or changes to existing untested code: Ensured that unit tests are added (See Ground Rules).
  • Large PR: Prepare changes in small commits for more convenient review
  • Bug fix: Add regression test for the bug
  • Bug fix: Add backport label to latest release (format: 'backport release-branch-name')

Verified locally: tests/everest/test_everlint.py + tests/everest/test_config_validation.py — 247 passed (the one failure in test_config_validation.py is pre-existing on main). Labels left for a maintainer.

This change was prepared with AI assistance; the regression test was run locally and fails without the fix.

check_writeable_path walks up from the configured path to the lowest
existing directory, but the loop only stopped on a directory that was
already writeable. An existing but unwritable simulation_folder therefore
did not terminate the walk: it kept climbing to an ancestor that happened
to be writeable and validation passed, so the error only surfaced when
every directory on the path was unwritable.

The walk now stops at the first existing directory, and the access check
after the loop decides whether to raise. A writeable folder still passes,
an unwritable one now raises the intended ValueError, and a non-existent
path still falls back to its nearest existing ancestor.

Removes the xfail from
test_that_simulation_folder_without_write_access_raises_validation_error,
which was added as a placeholder for this bug and now passes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Everest config validation so environment.simulation_folder (and other paths using check_writeable_path) fail fast when the target directory itself exists but is not writable, instead of incorrectly passing by walking up to a writable ancestor. This aligns validation with the intended behavior in issue #14056 and activates the previously xfailed regression test from #14055.

Changes:

  • Update check_writeable_path to stop walking at the first existing directory and perform the write/execute access check after the walk.
  • Remove xfail from test_that_simulation_folder_without_write_access_raises_validation_error so it now enforces the regression.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/everest/test_everlint.py Un-xfails the regression test asserting unwritable simulation_folder triggers a validation error.
src/everest/config/validation_utils.py Fixes directory walk logic so an existing but unwritable target directory correctly fails validation.

@ertomatic

Copy link
Copy Markdown
Collaborator

Screenshots differ from baselines. A baseline update PR has been prepared: equinor/ert-testdata#78

@codecov-commenter

codecov-commenter commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.82%. Comparing base (62b0035) to head (6408e1a).
⚠️ Report is 42 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14065      +/-   ##
==========================================
- Coverage   91.83%   91.82%   -0.01%     
==========================================
  Files         482      482              
  Lines       33444    33443       -1     
==========================================
- Hits        30713    30709       -4     
- Misses       2731     2734       +3     
Flag Coverage Δ
cli-tests 36.19% <0.00%> (+<0.01%) ⬆️
fuzz 44.10% <0.00%> (+<0.01%) ⬆️
gui-tests 58.40% <0.00%> (-0.01%) ⬇️
performance-and-unit-tests 80.45% <0.00%> (-0.01%) ⬇️
test 46.44% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/everest/config/validation_utils.py 88.65% <100.00%> (+0.45%) ⬆️

... and 1 file with indirect coverage changes

@codspeed-hq

codspeed-hq Bot commented Aug 6, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 36 untouched benchmarks


Comparing Sanjays2402:fix/writeable-path-checks-target-folder (6408e1a) with main (62b0035)

Open in CodSpeed

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.

validate_that_environment_sim_folder_is_writeable doesn't fail on unwritable folders

4 participants