fix(checkpoint): degrade non-array history instead of crashing resume - #29195
fix(checkpoint): degrade non-array history instead of crashing resume#29195soroush5 wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a stability issue where malformed checkpoint files containing non-array history data would cause the application to crash during the resume process. By validating the structure of the loaded checkpoint data, the system now gracefully degrades to an empty state when encountering corrupted files, ensuring consistent behavior across different failure scenarios. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
📊 PR Size: size/S
|
There was a problem hiding this comment.
Code Review
This pull request ensures that the 'history' property of a loaded checkpoint is validated as an array before returning it. If the history is not an array (e.g., due to file corruption), it is handled gracefully as a corrupt file, returning an empty history. Unit tests have been added to verify this behavior. I have no further feedback to provide.
|
/cla-check |
Summary
A checkpoint file with valid JSON but a non-array
historycrashed/resume resumewith a rawTypeError.loadCheckpointnow verifies the shape and degrades to an empty checkpoint, like it already does for unparseable files.Details
The object branch of
loadCheckpointonly checked that thehistorykey exists, then handed the raw value to resume — wherenull.length/number.slicethrew. Corrupt shapes like these come from a crash mid-save, a full disk, or a hand edit. The fix checksArray.isArraybefore returning parsed content; anything else falls through to the existing corrupt-file warning + empty checkpoint. Valid checkpoints (including extra fields likeauthType) are untouched.Related Issues
Fixes #29194
How to Validate
npx vitest run src/core/logger.test.tsinpackages/core— 41 passed, including 2 new wrong-shape regressions (null/number history).npm run preflight-relevant gates on touched files: ESLint zero warnings, Prettier clean.fs/pathlogic, platform-independent