fix: detect missing root hash in render command #60
Reference in New Issue
Block a user
Delete Branch "fix/53-render-missing-hash-error"
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?
What
Added validation in
render()andrenderAsync()functions to detect when the root hash doesn't exist in the CAS store and throwCasNodeNotFoundError.Why
Previously,
json-cas render AAAAAAAAAAAAAwith a non-existent hash would outputcas:AAAAAAAAAAAAAand exit with code 0. This was incorrect behavior - only nested missing nodes should render ascas:references. The root hash should be validated and fail fast.Changes
Added
CasNodeNotFoundErrorclass (variable-store.ts)Updated
render()andrenderAsync()(render.ts)CasNodeNotFoundErrorif root hash missingUpdated CLI error handling (
index.ts)CasNodeNotFoundErrorspecificallyTest coverage (11 new tests)
Testing
✅ All 390 tests pass (100% pass rate)
✅ Build clean:
bun run build✅ Lint clean:
bun run checkRef
Fixes #53
🤖 Generated with Claude Code
LGTM ✅ CasNodeNotFoundError 设计合理。