Python: FileCheckpointStorage save/load symmetry (#8181) - #8193
Closed
lsmlhi_25 (FOWEPJF255) wants to merge 1 commit into
Closed
Python: FileCheckpointStorage save/load symmetry (#8181)#8193lsmlhi_25 (FOWEPJF255) wants to merge 1 commit into
lsmlhi_25 (FOWEPJF255) wants to merge 1 commit into
Conversation
lsmlhi_25 (FOWEPJF255)
temporarily deployed
to
github-app-auth
September 9, 2026 14:14 — with
GitHub Actions
Inactive
lsmlhi_25 (FOWEPJF255)
temporarily deployed
to
github-app-auth
September 9, 2026 14:14 — with
GitHub Actions
Inactive
lsmlhi_25 (FOWEPJF255)
temporarily deployed
to
github-app-auth
September 9, 2026 14:15 — with
GitHub Actions
Inactive
lsmlhi_25 (FOWEPJF255)
temporarily deployed
to
github-app-auth
September 9, 2026 14:15 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Encoding and invalid-UTF-8 failures can still escape the documented exception contract.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Improves FileCheckpointStorage consistency between saving, loading, and listing.
Changes:
- Validates checkpoint restorability before saving.
- Wraps malformed JSON load failures.
- Aligns checkpoint ID filtering with checkpoint listing.
File summaries
| File | Description |
|---|---|
_checkpoint.py |
Updates save, load, and listing behavior. |
test_checkpoint.py |
Tests invalid JSON and listing consistency. |
test_checkpoint_unrestricted_pickle.py |
Tests save-time allow-list enforcement. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 3
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
331
to
+342
| checkpoint_dict = checkpoint.to_dict() | ||
| encoded_checkpoint = encode_checkpoint_value(checkpoint_dict) | ||
| # Fail at save time if this storage could not restore the payload (#8181). | ||
| try: | ||
| decode_checkpoint_value(encoded_checkpoint, allowed_types=self._allowed_types) | ||
| except WorkflowCheckpointException: | ||
| raise | ||
| except Exception as ex: | ||
| raise WorkflowCheckpointException( | ||
| f"Checkpoint {checkpoint.checkpoint_id} cannot be restored under this " | ||
| "storage's allowed types; refusing to save." | ||
| ) from ex |
| encoded_checkpoint = await asyncio.to_thread(_read) | ||
| try: | ||
| encoded_checkpoint = await asyncio.to_thread(_read) | ||
| except json.JSONDecodeError as ex: |
Comment on lines
+480
to
+484
| decoded_checkpoint_dict = decode_checkpoint_value( | ||
| encoded_checkpoint, allowed_types=self._allowed_types | ||
| ) | ||
| checkpoint = WorkflowCheckpoint.from_dict(decoded_checkpoint_dict) | ||
| if checkpoint.workflow_name == workflow_name: |
Contributor
|
Closing as PR doesn't use our required pull request template. |
5 tasks
Contributor
Author
|
Reopened with the required PR template as #8214 (also addresses prior Copilot notes on encode/UTF-8/list_ids). |
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
allowed_checkpoint_typesbefore writing, so save refuses payloads that load would reject.loadasWorkflowCheckpointException.list_checkpoint_idswithlist_checkpointsdecode filtering.Closes #8181
Test plan
test_file_storage_rejects_unlisted_user_type_at_savetest_file_checkpoint_storage_load_invalid_json_raisestest_file_checkpoint_storage_list_ids_matches_list_decode_filter