Repository navigation
feat: type changes for trailer hash - #82
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Union decoding can materialize unbounded input before variant limits are enforced, creating a critical memory-consumption risk.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Adds digest-aware blob types and propagates computed trailer hashes through HTTP PUT results.
Changes:
- Adds blob specification and reject-argument unions.
- Updates generated CBOR/DAG-JSON codecs and tests.
- Extends PUT results with optional computed digests.
| File | Description |
|---|---|
commands/internal/codec/codec.go |
Shared union decoding helpers |
commands/http/types.go |
PUT result types |
commands/http/put.go |
Updated PUT result binding |
commands/http/put_test.go |
PUT result tests |
commands/http/json_gen.go |
Generated JSON codecs |
commands/http/gen/main.go |
HTTP model registration |
commands/http/cbor_gen.go |
Generated CBOR codecs |
commands/blob/types.go |
Blob and reject union types |
commands/blob/spec_test.go |
Blob union tests |
commands/blob/json_gen.go |
Generated JSON codecs |
commands/blob/gen/main.go |
Blob model registration |
commands/blob/codec.go |
Blob union codecs |
commands/blob/cbor_gen.go |
Generated CBOR codecs |
commands/blob/accept.go |
Digest mismatch error |
commands/blob/abort_test.go |
Reject argument tests |
Files not reviewed (4)
- commands/blob/cbor_gen.go: Generated file
- commands/blob/json_gen.go: Generated file
- commands/http/cbor_gen.go: Generated file
- commands/http/json_gen.go: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Blob decoding can accept an invalid empty digest when conflicting fields are supplied.
Review effort: Lite
Findings: 1
Open (1)
Resolved since last review (1)
Files not reviewed (4)
- commands/blob/cbor_gen.go: Generated file
- commands/blob/json_gen.go: Generated file
- commands/http/cbor_gen.go: Generated file
- commands/http/json_gen.go: Generated file
| switch hasDigest := len(m.Digest) > 0; { | ||
| case hasDigest && m.DigestCode == nil: | ||
| s.blob = &Blob{Digest: m.Digest, Size: m.Size} | ||
| case !hasDigest && m.DigestCode != nil: | ||
| s.code = &BlobDigestCode{DigestCode: *m.DigestCode, Size: m.Size} |
There was a problem hiding this comment.
🤷♂️ this is super edge case and IMO not worth the complexity to enforce. An empty digest is not a valid multihash so it cannot possibly be the variant that should be used.


refs fil-one/RFC#31