mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[GH-ISSUE #96] posixfs catalog: write_commit_marker uses path.parent().unwrap() that can panic #32
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#32
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?
Originally created by @hi-neason on GitHub (Jul 31, 2026).
Original GitHub issue: https://github.com/kvcache-ai/AgentENV/issues/96
Affected component
Snapshot / template builder
AgentENV version
a33198e671(main)Host environment
Operation and configuration
When publishing a snapshot using the POSIX filesystem repository backend,
PosixFsCatalog::write_commit_markeris invoked fromcommit_session(catalog.rs:110) and frompublish_session_snapshot(catalog.rs:117) as part of the normal snapshot commit flow. The path passed in comes fromself.commit_marker_path(id).Steps to reproduce
A panic requires
commit_marker_path(id)to yield aPathwith no parent. With the current default config this does not happen because the root is an absolute directory, but the same function guards thecreate_dir_allcall withif let Some(parent) = path.parent()six lines earlier, explicitly acknowledging thatpath.parent()can beNone. The sibling methodwrite_json(line 403-406) already handles the case correctly:The unwrap on line 441 is therefore an inconsistency that will panic if a bare/relative root (e.g.
"."or a filename-only root) is ever used, or if a future change tocommit_marker_pathreturns a bare filename.Static reproduction:
Note line 395/403 (in
write_json) and line 435 (inwrite_commit_markeritself) all handleNonedefensively; only line 441 unwraps.Expected behavior
write_commit_markershould return aRepositoryError::Backendwhenpath.parent()isNone, matching the pattern already used inwrite_jsonat lines 403-406, instead of panicking the task and potentially taking down the server thread.Actual behavior
path.parent().unwrap()will panic on aNoneparent with a generic "calledOption::unwrap()on aNonevalue" message, bypassing theRepositoryResulterror channel.Logs and diagnostics
N/A (static analysis finding).
Reproduction frequency
Conditional — only triggers when
commit_marker_pathreturns a path with no parent, but the presence of the defensive check 6 lines above confirms the None case was anticipated by the author.Regression information
Additional context
This is a small, low-risk consistency fix (~5 LOC) that replaces the
.unwrap()with the sameok_or_elsepattern already used in the sibling method. I am happy to send a PR if the approach looks good.Pre-submission checklist