Repository navigation
fix(serializers): keep strings that only start with a date as strings - #1353
Open
RaphaelFakhri wants to merge 7 commits into
Open
RaphaelFakhri wants to merge 7 commits into
RaphaelFakhri wants to merge 7 commits into
Conversation
Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change that preserves date-prefixed strings when parsing fails.
No open issues 🎉
What changed in this PR
Fixes #1352 by preserving date-prefixed strings when date parsing fails, preventing deserialization errors in actor state and payloads while retaining existing datetime conversion behavior.
Changes:
- Catch
ValueErrorandOverflowErrorduring date parsing and return the original string. - Add regression coverage for date-prefixed notes and filenames using hyphen and slash separators.
| File | Description |
|---|---|
tests/serializers/test_default_json_serializer.py |
Verifies that date-prefixed text remains unchanged. |
dapr/serializers/json.py |
Falls back to the original string when date parsing fails. |
Review effort: Balanced
sicoyle
approved these changes
Nov 6, 2026
sicoyle
left a comment
Contributor
There was a problem hiding this comment.
amazing - thank you for this great and very focused contribution!! you rock 🚀
dapr-bot
enabled auto-merge
November 6, 2026 15:11
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1353 +/- ##
=======================================
Coverage 88.72% 88.73%
=======================================
Files 166 166
Lines 13632 13635 +3
=======================================
+ Hits 12095 12099 +4
+ Misses 1537 1536 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Description
DaprJSONDecoder.custom_scanstringsends every string whose prefix matches\d{4}[-/]\d{2}[-/]\d{2}todateutil.parser.parse. When the rest of the string is not part of a date, as in'2024-01-01 meeting notes', the parser raisesParserErrorand the whole deserialization fails. This breaks reading actor state and actor method payloads that contain such strings.This change catches
ValueError(the base class ofParserError) andOverflowErrorfrom the parser and returns the original string. Strings that parse as dates still decode todatetime, so existing behavior doesn't change for them.Issue reference
Fixes #1352
Checklist