Repository navigation
Conversation
ColtenOuO
reviewed
Aug 24, 2026
ColtenOuO
left a comment
Contributor
There was a problem hiding this comment.
follow the same suggestion in #71880
Also, the issue author mentioned they were already planning to submit a PR for this. It might not be ideal to open a PR over them, so you might want to keep that in mind when picking up issues in the future.
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
The 0049 migration's NaN sanitizer (
regexp_replace) incorrectly matchesNaN/Infinitytokens inside JSON string values, injecting an unescaped quote that breaks the outer JSON structure. This causes the migration to abort withINVALID_TEXT_REPRESENTATIONon PostgreSQL and equivalent errors on MySQL/SQLite, making the upgrade 2.x → 3.x fail for any XCom value that is a JSON string wrapping a JSON document containing NaN floats.This happens when:
json.dumps(json.dumps({"amount": float("nan")}))){"report": "{\"amount\": NaN}"})Both shapes are already valid JSON — the NaN token lives inside a JSON string, not at the JSON syntax level. The sanitizer should not touch them.
Fix
Guard the per-dialect sanitize SQL with the native JSON validity check for each engine:
json_valid()JSON_VALID()json_valid()Values that are already valid JSON pass through the sanitizer untouched; only values containing bare NaN/Infinity tokens (which are illegal in strict JSON/JSONB) are quoted.
Tests
test_sqlite_sanitize_skips_already_valid_json— regression test for both shapes using the SQLite branch (backend-independent).TestPostgresSanitize/TestMysqlSanitizecontinue to pass (bare NaN/Infinity are still quoted correctly).Closes #71921