Skip to content

Raise FileNotFoundError for missing local files in guess_engine#11150

Merged
jsignell merged 1 commit intopydata:mainfrom
kkollsga:fix-10896-missing-file-error
Feb 10, 2026
Merged

Raise FileNotFoundError for missing local files in guess_engine#11150
jsignell merged 1 commit intopydata:mainfrom
kkollsga:fix-10896-missing-file-error

Conversation

@kkollsga
Copy link
Contributor

@kkollsga kkollsga commented Feb 9, 2026

Summary

When open_dataset("missing.h5") is called with a non-existent local file, guess_engine() now raises a clear FileNotFoundError instead of the confusing ValueError: did not find a match in any of xarray's currently installed IO backends.

The check runs only in the error path of guess_engine() (after all backends have already failed to match), so it has zero impact on the happy path. Remote URIs are excluded using the existing is_remote_uri() helper, and existing files with unrecognized extensions still produce the original ValueError.

Test plan

  • test_guess_engine_file_not_found — verifies FileNotFoundError for string paths, PathLike objects, and that remote URIs still raise ValueError
  • Updated test_no_matching_engine_found and test_engines_not_installed to account for the new behavior
  • Pre-commit (ruff, formatting) passes
  • Mypy — no new errors introduced

…ta#10896)

When `open_dataset` is called with a non-existent local file path,
`guess_engine` now raises `FileNotFoundError` instead of a confusing
"no backend found" `ValueError`. Remote URIs are not affected.

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Member

@jsignell jsignell left a comment

Choose a reason for hiding this comment

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

This looks great @kkollsga!

@jsignell jsignell merged commit 160a85c into pydata:main Feb 10, 2026
40 checks passed
@kkollsga kkollsga deleted the fix-10896-missing-file-error branch February 10, 2026 22:03
tonybaloney pushed a commit to tonybaloney/swe-complex-xarray that referenced this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

open_dataset should fail early, before reaching guess_engine when file doesn't exist

2 participants