Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3ba4a64886
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| val nodes = requireNotNull(envelope["piece layers"]?.dictionary) { | ||
| "Imported metainfo requires a piece layers dictionary" | ||
| } |
There was a problem hiding this comment.
Accept omitted piece-layer dictionaries for small torrents
When a valid v2 metainfo contains no file larger than pieceLength, BEP 52 permits piece layers to be omitted, and validatePieceLayers(emptyMap()) can already authenticate that case. This requireNotNull rejects such documents before validation, so empty, one-byte, and single-piece torrents cannot be imported unless a producer injects an unnecessary empty dictionary. Treat a missing field as an empty map while continuing to reject missing layers when the file tree requires them.
AGENTS.md reference: AGENTS.md:L242-L245
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The current BEP 52 explicitly says a torrent is invalid when this field is absent (lines 93–106): https://github.com/bittorrent/bittorrent.org/blob/master/beps/bep_0052.rst#L93-L106 . I am retaining the required dictionary check, including for small torrents. An empty dictionary is accepted for files that need no external layers; info-only magnet metadata follows a separate path. Relaxing document import here would conflict with the specification.
|
Superseded by #232 (V2 identity, metainfo and Merkle integrity) in the consolidated eight-PR stack for #162. The replacement preserves this PR's code and subsequent fixes; its description links the original head and review discussions. The only additional consolidation fix is the CI-discovered listener cancellation regression, documented on the replacement. All eight replacements have passed their required CI checks. Closing without merging. This branch and its discussions remain available for reference. Review index: #162 (comment) |
Require document-level piece-layer validation for bounded v2 imports and validate the v1 layout when a document is hybrid. Imported metainfo must include its required authenticated layers; info-only BEP 9 responses cannot pass as complete documents.
Part of #162, stacked on #172 (
torrent-v2-04-info). Hybrid validation requires identical raw filenames, order, lengths and piece alignment, checks v1 hash counts, and retains original v1 file indices. Padding becomes virtual zero spans; omitted padding paths and optional trailing padding are supported. Partial/conflicting layouts and symlinks are rejected.Validation: all 342 local torrent tests passed with none skipped, both pinned-client conformance scenarios executed, and the native-runtime dependency guard passed. Coverage includes independent envelope/info/layer bounds, corrupt or missing layers, empty/small files, single/multi-file hybrids, and incorrect names/order/lengths/alignment/hash counts.
This is the bounded in-memory import path. Large streaming/spilled imports, safe output mapping, runtime routing, and dual payload verification still need integration before v2/hybrid download support is advertised. Metadata consistency does not prove that payload matches both hash schemes.