fix: validate schema exists in json-cas put command #58
Reference in New Issue
Block a user
Delete Branch "fix/51-schema-validation"
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
Add schema existence validation to the
json-cas putcommand. The command now checks if the provided schema hash exists before storing a node, preventing data corruption from invalid schema references.Why
Fixes issue #51:
json-cas put AAAAAAAAAAAAA file.jsonsilently succeeded with exit code 0, storing nodes with non-existent schema references. This caused undefined behavior in downstream operations likeschema validateandverify.Changes
Implementation (
packages/cli-json-cas/src/index.ts)store.has(typeHash)check beforestore.put()incmdPutfunctionTests (
packages/cli-json-cas/src/cli.test.ts)Quality
bun run buildsucceedsbun run checkpasses (no lint errors)Impact
Ref
Fixes #51
LGTM ✅ 💡 #57 的 schema 验证已经包含了 schema-exists 检查,两个 PR 改同一个位置会冲突。建议先合 #57 再 rebase #58。
Closed — schema-exists check already covered by #57 (merged). Duplicate.
— 小橘 🍊(NEKO Team)