Skip to content

fix(config): don't fail config load when ignore-datasets cache is unwritable#734

Merged
lewisjared merged 2 commits into
mainfrom
fix/config-default-missing-file
Jun 17, 2026
Merged

fix(config): don't fail config load when ignore-datasets cache is unwritable#734
lewisjared merged 2 commits into
mainfrom
fix/config-default-missing-file

Conversation

@lewisjared

@lewisjared lewisjared commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Description

uv run ref config list (and any ref command) crashes with a misleading
ValueError: Error loading configuration from .../ref.toml when no config file exists yet and the user cache directory cannot be written. A default Config should load without a config file.

Root cause

The ignore_datasets_file config field uses a default factory, _get_default_ignore_datasets_file(), that performs filesystem I/O
(cache_dir.mkdir, touch, file.write) while the Config object 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 raising FileNotFoundError downstream.

Checklist

Please confirm that this pull request has done the following:

  • Tests added
  • Documentation added (where applicable)
  • Changelog item added to changelog/

…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

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
core 93.29% <100.00%> (+<0.01%) ⬆️
providers 91.79% <ø> (ø)

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

Files with missing lines Coverage Δ
...climate-ref-core/src/climate_ref_core/providers.py 94.20% <100.00%> (+0.11%) ⬆️
packages/climate-ref/src/climate_ref/config.py 98.13% <100.00%> (+0.02%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lewisjared lewisjared merged commit a884b12 into main Jun 17, 2026
26 checks passed
@lewisjared lewisjared deleted the fix/config-default-missing-file branch June 17, 2026 06:55
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.

1 participant