fix(config): don't fail config load when ignore-datasets cache is unwritable#734
Merged
Conversation
…ritable `Config.default()` raised a misleading "Error loading configuration" when no config file existed and the user cache directory could not be written (e.g. a read-only or otherwise restricted HPC environment). The `ignore_datasets_file` default factory performs filesystem I/O during structuring, and only network errors were guarded — an `OSError` from `mkdir`/`touch`/`write` propagated and was swallowed into a generic `ValueError`. Acquiring the default ignore-datasets file is a best-effort optimisation, so: - `_get_default_ignore_datasets_file()` now degrades gracefully on any filesystem error, logging a warning and returning the (possibly missing) path instead of breaking config loading. - `DiagnosticProvider.configure()` tolerates an absent ignore-datasets file, treating it as "ignore nothing" rather than raising `FileNotFoundError`.
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 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.
Description
uv run ref config list(and anyrefcommand) crashes with a misleadingValueError: Error loading configuration from .../ref.tomlwhen no config file exists yet and the user cache directory cannot be written. A defaultConfigshould load without a config file.Root cause
The
ignore_datasets_fileconfig field uses a default factory,_get_default_ignore_datasets_file(), that performs filesystem I/O(
cache_dir.mkdir,touch,file.write) while theConfigobject is being structured.Fix
Acquiring the default ignore-datasets file is a best-effort optimisation, so:
_get_default_ignore_datasets_file()now degrades gracefully on any filesystem error, logging a warning and returning the (possibly missing) path instead of breaking config loading.DiagnosticProvider.configure()tolerates an absent ignore-datasets file, treating it as "ignore nothing" rather than raisingFileNotFoundErrordownstream.Checklist
Please confirm that this pull request has done the following:
changelog/