mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #104] [MERGED] fix(snapshot): return error instead of panicking in write_commit_marker #179
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#179
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/104
Author: @Loken-Lau
Created: 8/2/2026
Status: ✅ Merged
Merged: 8/4/2026
Merged by: @yingdi-shan
Base:
main← Head:fix/posixfs-commit-marker-parent📝 Commits (1)
e7171b3fix(snapshot): return error instead of panicking in write_commit_marker📊 Changes
1 file changed (+13 additions, -12 deletions)
View changed files
📝
src/snapshot/repository/backends/posixfs/catalog.rs(+13 -12)📄 Description
What
PosixFsCatalog::write_commit_markerguarded thecreate_dir_allcall withif let Some(parent) = path.parent(), but then calledpath.parent().unwrap()when creating the temp commit marker file. Ifcommit_marker_pathever yields a parentless path, the defensive check isbypassed and the function panics instead of returning a
RepositoryError.This change resolves the parent once up front with
ok_or_else, returns aRepositoryError::Backendwhen it is absent, and reuses it for bothcreate_dir_allandNamedTempFile::new_in— matching the pattern alreadyused by
write_json_atomicin the same file. It also removes the lastunwrap()fromposixfs/catalog.rs.Why
A snapshot repository backend must never panic on an unexpected path shape;
commit failures should surface as typed
RepositoryErrors so callers canhandle them. The mixed checked/unchecked usage was also internally
inconsistent.
Related issue
Closes #96
Scope and non-goals
write_commit_markererror handling only.commit_marker_pathlayout, touching other backends,or auditing other crates for similar
unwrap()patterns.Design and behavior changes
No behavior change for existing configurations where the parent always
exists. For the previously panicking edge case, the function now returns
RepositoryError::Backend { message: "resolve parent for '<path>'" }.Compatibility and operations
Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes)maketargetCommands and results (WSL2, Ubuntu, kernel 6.18.33.2-microsoft-standard-WSL2):
Skipped checks and reasons
make test-integration) andmake test-ublk:this development environment is WSL2, whose stock kernel does not ship the
ublk_drvmodule (/dev/ublk-controlabsent) and restricts io_uring, sooverlaybd/ublk-backed tests cannot run here (attempted: overlaybd tests
fail at lower-layer open with io_uring errors — an environment limitation,
not related to this change). These paths are covered by CI on proper Linux
hosts with
/dev/kvm+ ublk.make test-envd: requires a running Docker daemon, not available in thisenvironment.
All unit tests covering the touched subsystem pass, including the posixfs
catalog/backend suites (
begin_and_commit_make_snapshot_visible,publishes_gets_and_resolves_snapshot,failed_commit_cleans_uncommitted_ snapshot_directory, etc.) that exercise the commit-marker flow.Risks and reviewer notes
Low risk: pure error-handling change in one function; the new error path is
unreachable with the current default config (repository root is an absolute
directory), so existing deployments see no behavioral difference.
Checklist
(The parentless-path branch is unreachable through current public
constructors; existing posixfs commit-flow tests all pass.)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.