H-4170: Load optional TOML files in hash-config - #9566
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
PR SummaryMedium Risk Overview Required and optional paths now share one ordered Integration tests cover optional absence, deferred read/removal before load, mixed required/optional ordering, and extend existing error/redaction cases to optional layers. Reviewed by Cursor Bugbot for commit be8b00f. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches the stated semantics and includes comprehensive coverage for precedence, absence, and error handling.
Pull request overview
Adds optional TOML configuration layers to hash-config while preserving required-file behavior and source precedence.
Changes:
- Adds
Loader::with_optional_toml_file, skipping only missing files. - Includes the selected format in parse errors.
- Expands tests for ordering, deferred reads, errors, and redaction.
File summaries
| File | Description |
|---|---|
libs/@local/config/src/lib.rs |
Exposes and documents optional TOML loading. |
libs/@local/config/src/file.rs |
Implements required/optional file sources and format-aware errors. |
libs/@local/config/src/error.rs |
Adds file format details to parse errors. |
libs/@local/config/tests/files.rs |
Covers optional-file behavior and failure cases. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9566 +/- ##
=======================================
Coverage 65.93% 65.93%
=======================================
Files 1885 1885
Lines 198175 198188 +13
Branches 8230 8232 +2
=======================================
+ Hits 130672 130685 +13
Misses 65972 65972
Partials 1531 1531
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🌟 What is the purpose of this PR?
Allow binaries to add a local TOML configuration file that may be absent.
with_optional_toml_file("hash-graph.local.toml")leaves lower-priority values intact when the file is missing, while unreadable or malformed files still fail the load.🔗 Related links
🚫 Blocked by
None.
🔍 What does this change?
Loader::with_optional_toml_file. Read files at load time and skip onlyio::ErrorKind::NotFound; preserve other I/O causes, paths, and value redaction.FileFormat::TomltoLoadError::ParseFileand use it in the existing error message. The selected parser determines the format, independent of the path's extension.Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
Optional loading skips errors classified as
NotFound, including missing parent directories. Automatic discovery and additional file formats remain outside this slice.🐾 Next steps
Verify provenance for content diagnostics after merging multiple sources: attribute an invalid surviving value to its supplying source, allow later values to correct earlier ones, and avoid attributing missing required values to an arbitrary file.
🛡 What tests cover this?
37 unit, integration, and example tests, including existing report snapshots, and 3 executable Rustdoc tests pass. Coverage includes absent files and parent directories, deferred reads, removal before load, mixed file order above defaults, read/parse/deserialization errors, redaction, and explicit format selection. Clippy with warnings denied and Rustdoc also pass.
❓ How to test this?
📹 Demo
The executable
with_optional_toml_fileRustdoc example demonstrates a local file overriding a default port. No UI is involved.