fix(config): surface parent-mkdir failure before write_config attempt (#188)#246
Closed
SAY-5 wants to merge 2 commits intoTrueNine:devfrom
Closed
fix(config): surface parent-mkdir failure before write_config attempt (#188)#246SAY-5 wants to merge 2 commits intoTrueNine:devfrom
SAY-5 wants to merge 2 commits intoTrueNine:devfrom
Conversation
Fix two CI failures from previous merge
Closes TrueNine#188. `write_config` did `let _ = fs::create_dir_all(parent)` and discarded the error. If `mkdir -p` failed (perms, EROFS, ENOSPC), the subsequent `fs::write(path, …)` would fail too — but with a secondary "No such file or directory" error that didn't point at the actual cause. Operators saw `CONFIG_WRITE_FAILED` and assumed the destination was unwritable, when really the parent never existed because `create_dir_all` had been silently swallowed. Bind the result and emit a `CONFIG_PARENT_DIR_CREATE_FAILED` diagnostic on `Err`, then `return` so we don't pile a confusing `CONFIG_WRITE_FAILED` on top. Operators now see the real failing step with the parent path + io::Error message, and the suggestion points at "parent path is writable / not on read-only or full filesystem" rather than the generic destination check. The serialization and write paths are unchanged. Behaviour on the happy path (parent exists, mkdir succeeds, write succeeds) is identical. `cargo build --manifest-path sdk/Cargo.toml` clean. `cargo test --lib domain::config` is green (24/24).
Owner
|
Merged into dev via cherry-pick. The PR base was changed from main to dev, which caused conflicts because dev had diverged significantly. All commits have been cherry-picked onto dev and pushed. Thanks for the contributions! |
Owner
|
Thank you for the contribution! All commits have been cherry-picked and merged into the dev branch. 🙏 |
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.
Closes #188.
write_configdidlet _ = fs::create_dir_all(parent)and discarded the error. Ifmkdir -pfailed (perms, EROFS, ENOSPC), the subsequentfs::write(path, …)would fail too — but with a secondary No such file or directory that didn't point at the actual cause. Operators sawCONFIG_WRITE_FAILEDand assumed the destination was unwritable, when really the parent never existed becausecreate_dir_allhad been silently swallowed.Fix
Bind the result and emit a
CONFIG_PARENT_DIR_CREATE_FAILEDdiagnostic onErr, thenreturnso we don't stack a misleadingCONFIG_WRITE_FAILEDon top. Operators now see the real failing step with the parent path + io::Error message, and the suggestion points at parent path is writable / not on read-only or full filesystem rather than the generic destination check.Happy path (parent exists, mkdir succeeds, write succeeds) is unchanged.
Test plan
cargo build --manifest-path sdk/Cargo.toml— cleancargo test --manifest-path sdk/Cargo.toml --lib domain::config— 24/24 pass