Skip to content

fix(config): surface parent-mkdir failure before write_config attempt (#188)#246

Closed
SAY-5 wants to merge 2 commits intoTrueNine:devfrom
SAY-5:fix/write-config-parent-mkdir-188
Closed

fix(config): surface parent-mkdir failure before write_config attempt (#188)#246
SAY-5 wants to merge 2 commits intoTrueNine:devfrom
SAY-5:fix/write-config-parent-mkdir-188

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented Apr 29, 2026

Closes #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 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.

Fix

Bind the result and emit a CONFIG_PARENT_DIR_CREATE_FAILED diagnostic on Err, then return so we don't stack a misleading 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.

Happy path (parent exists, mkdir succeeds, write succeeds) is unchanged.

Test plan

  • cargo build --manifest-path sdk/Cargo.toml — clean
  • cargo test --manifest-path sdk/Cargo.toml --lib domain::config — 24/24 pass

TrueNine and others added 2 commits April 25, 2026 10:10
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).
@SAY-5 SAY-5 requested a review from TrueNine as a code owner April 29, 2026 22:46
@TrueNine TrueNine changed the base branch from main to dev April 30, 2026 08:08
@TrueNine
Copy link
Copy Markdown
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!

@TrueNine TrueNine closed this Apr 30, 2026
@TrueNine
Copy link
Copy Markdown
Owner

Thank you for the contribution! All commits have been cherry-picked and merged into the dev branch. 🙏

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.

[Config] write_config 静默忽略目录创建失败

2 participants