Handle unknown chunk types gracefully - #46
Closed
mpicciolli wants to merge 9 commits into
Closed
Conversation
readChunk() threw on any chunk type it didn't recognize. A future PCM version adding a new chunk type to the save format would make this library unable to read those saves at all, even for tables/chunks it otherwise understands. Since every chunk header carries its own chunkSize, an unknown chunk can be skipped by byte count (with a warning) instead of aborting, preserving forward compatibility. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…-unknown-chunk-types
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the CDB binary parser to tolerate unknown chunk types so parsing can continue (instead of failing fast), and adds tests to validate the new behavior. It also updates package version metadata.
Changes:
- Update
CDBReader.readChunk()to warn and consume bytes for unknown chunk types rather than throwing. - Add Vitest coverage for unknown-chunk handling (including invalid-size error behavior).
- Bump package version fields in
package.json/package-lock.json(note: version differs from PR description).
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/reader.ts |
Implements unknown-chunk handling by warning and returning raw bytes instead of throwing. |
test/reader.test.ts |
Adds tests ensuring unknown chunks are tolerated and invalid unknown chunk sizes still error. |
package.json |
Updates package version metadata. |
package-lock.json |
Keeps lockfile version metadata in sync with package.json. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| "name": "cdb-converter", | ||
| "version": "0.2.0", | ||
| "version": "0.3.0", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
npm test(78 tests passed)npm run build