Python: reject malformed checkpoint Base64 payloads - #8262
Conversation
|
fzfzzfzzzfzzzz please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, aligns behavior with documented expectations, and includes a targeted regression test covering the new strict validation behavior.
Pull request overview
This PR tightens Python checkpoint decoding to reject malformed Base64 pickle payloads by enabling strict Base64 validation, aligning runtime behavior with the documented WorkflowCheckpointException error path.
Changes:
- Switch checkpoint pickle payload decoding to
base64.b64decode(..., validate=True)to reject non-Base64 characters. - Add a regression test that appends illegal trailing characters to an otherwise valid pickled checkpoint payload and asserts
WorkflowCheckpointException.
File summaries
| File | Description |
|---|---|
| python/packages/core/agent_framework/_workflows/_checkpoint_encoding.py | Enables strict Base64 validation when decoding pickled checkpoint payloads so malformed envelopes fail deterministically. |
| python/packages/core/tests/workflow/test_checkpoint_decode.py | Adds a regression test ensuring malformed Base64 pickle payloads raise WorkflowCheckpointException. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Motivation & Context
base64.b64decode()is permissive by default and silently discards non-Base64 characters. As a result, a malformed checkpoint pickle payload can be accepted and decoded instead of producing the documentedWorkflowCheckpointException.Description & Review Guide
encode_checkpoint_value()are unchanged.Related Issue
Fixes #8257
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.