fix: handle disc identification edge cases#12
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis PR updates copyright headers from 2025 to 2026 across most repository files. It also changes path-identification fallback behavior, improves PlayStation serial extraction, adds bounds checks in Sega CD/SNES parsing, adjusts CHD byte masking, removes lint suppressions, updates ISO9660 block-device handling and read-size limits, simplifies one N64 test helper, and bumps the Go toolchain version. ChangesFunctional and safety fixes
Estimated code review effort: 3 (Moderate) | ~25 minutes Copyright Year Updates
Toolchain Update
Related Issues: Not specified. Related PRs: Not specified. Suggested labels: enhancement, bug, chore Suggested reviewers: Not specified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
iso9660/iso9660.go (1)
397-407: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSolid bounds check; consider exposing the cap if reuse beyond identification is anticipated.
The size check and error wrapping are correct and well-documented.
maxReadFileSizeis currently private and fixed at 16MiB — fine for the current identification-only use case, but ifReadFileis later used to extract full game files elsewhere in the codebase, this cap could unexpectedly reject legitimate larger reads.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iso9660/iso9660.go` around lines 397 - 407, The size guard in ReadFile is correct, but maxReadFileSize is a private fixed limit that may block future legitimate callers; update the ISO9660 package to make the read cap configurable or exported so reuse beyond identification can adjust it as needed, and keep ReadFile using that shared limit constant/value.gameid.go (1)
291-302: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate error-handling pattern; consider extracting a shared helper.
This block repeats the same
IdentifyFromPath→errors.As(identifier.NotSupportedError)fallback pattern as Lines 141-154. The same type-matching concern raised there applies here as well. Extracting a small helper (e.g.,identifyFromPathOrFallbackor anisNotSupported(err) boolpredicate) would avoid the two call sites silently diverging if the contract changes later.♻️ Example helper extraction
+func isNotSupportedErr(err error) bool { + var notSupported identifier.NotSupportedError + return errors.As(err, ¬Supported) +} + func identifyFromBlockDevice(path string, _ Console, ident identifier.Identifier, database identifier.Database) (*Result, error) { if pid, ok := ident.(pathIdentifier); ok { result, err := pid.IdentifyFromPath(path, database) if err == nil { return result, nil } - var notSupported identifier.NotSupportedError - if !errors.As(err, ¬Supported) { + if !isNotSupportedErr(err) { return nil, fmt.Errorf("identify from path: %w", err) } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@gameid.go` around lines 291 - 302, This block duplicates the IdentifyFromPath fallback logic already used elsewhere, so extract the shared error-handling into a helper to keep both call sites consistent. Move the path-based identification and identifier.NotSupportedError check into a small reusable function or predicate (for example, one used by gameID identification flow in gameid.go), then update this branch to call that helper and preserve the current fallback-to-raw-block-device behavior only when the error is NotSupported.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@gameid.go`:
- Around line 291-302: This block duplicates the IdentifyFromPath fallback logic
already used elsewhere, so extract the shared error-handling into a helper to
keep both call sites consistent. Move the path-based identification and
identifier.NotSupportedError check into a small reusable function or predicate
(for example, one used by gameID identification flow in gameid.go), then update
this branch to call that helper and preserve the current
fallback-to-raw-block-device behavior only when the error is NotSupported.
In `@iso9660/iso9660.go`:
- Around line 397-407: The size guard in ReadFile is correct, but
maxReadFileSize is a private fixed limit that may block future legitimate
callers; update the ISO9660 package to make the read cap configurable or
exported so reuse beyond identification can adjust it as needed, and keep
ReadFile using that shared limit constant/value.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e7e86d2b-fba1-4388-8f32-b5dee5c5c2bf
📒 Files selected for processing (71)
archive/archive.goarchive/archive_test.goarchive/detect.goarchive/detect_test.goarchive/errors.goarchive/errors_test.goarchive/path.goarchive/path_test.goarchive/rar.goarchive/sevenzip.goarchive/zip.goblockdevice_unix.gochd/bitstream.gochd/chd.gochd/chd_test.gochd/codec.gochd/codec_flac.gochd/codec_lzma.gochd/codec_zlib.gochd/codec_zstd.gochd/errors.gochd/header.gochd/hunk.gochd/metadata.gocmd/dbgen/main.gocmd/gameid/main.goconsole.goconsole_test.godatabase.godatabase_test.gogameid.gogameid_test.goidentifier/fuzz_test.goidentifier/gb.goidentifier/gb_test.goidentifier/gba.goidentifier/gba_test.goidentifier/gc.goidentifier/gc_test.goidentifier/genesis.goidentifier/genesis_test.goidentifier/identifier.goidentifier/n64.goidentifier/n64_test.goidentifier/neogeocd.goidentifier/neogeocd_test.goidentifier/nes.goidentifier/nes_test.goidentifier/ps2.goidentifier/ps2_test.goidentifier/psp.goidentifier/psp_test.goidentifier/psx.goidentifier/psx_test.goidentifier/saturn.goidentifier/saturn_test.goidentifier/segacd.goidentifier/segacd_test.goidentifier/snes.goidentifier/snes_test.gointernal/binary/fuzz_test.gointernal/binary/reader.gointernal/binary/reader_test.goiso9660/chd.goiso9660/cue.goiso9660/cue_test.goiso9660/fuzz_test.goiso9660/iso9660.goiso9660/iso9660_test.goiso9660/mounted.goiso9660/mounted_test.go
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@go.mod`:
- Line 3: The release workflow is still using an older Go version than the
module requires, so update the Go setup in the release pipeline to match the
version declared in go.mod. Find the Go version configuration in the release
workflow and change it to the same 1.26.4-compatible version used by the module
so release builds use the correct toolchain.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Summary
Tests
Summary by CodeRabbit