Repository navigation
Conversation
Content decoded from a template arrives as a str_node, which decode_str rejects with a generic parser error, so every string-form document was reported invalid. Convert to a plain str before decoding; the decoded document gets fresh source marks from parsing the string itself, so no location information is lost. Fixes aws-cloudformation#4894 Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
Contributor
Author
|
Hi kddejong, this PR's CI is parked at the first-time-contributor approval gate (the github-actions run shows action_required). Could you approve the workflow run when you have a moment? Thanks! |
This was referenced Oct 27, 2026
# Conflicts: # test/unit/rules/resources/ssm/test_document.py
kddejong
approved these changes
Oct 30, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4902 +/- ##
=======================================
Coverage 94.73% 94.73%
=======================================
Files 442 442
Lines 16088 16088
Branches 3121 3121
=======================================
Hits 15241 15241
Misses 467 467
Partials 380 380
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ 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.
Fixes #4894
Problem
E3051 cannot validate an
AWS::SSM::DocumentwhoseContentis a JSON string rather than an object. Every such document was reported invalid with the same parser error, whether the JSON was well-formed or not:Root cause
Content decoded from a template arrives as a
str_node(astrsubclass carrying source marks), andcfnlint.decode.decode_strrejects it instead of treating it as a string, so parsing fails before the document is ever examined. This affects all document types, not just one.Fix
Convert to a plain
strbefore callingdecode_strinsrc/cfnlint/rules/resources/ssm/Document.py. The decoded document gets fresh source marks from parsing the string itself, so no location information is lost by the conversion.This is independent of #4844: the branch is built on current upstream main without #4844, and #4844's early return for AppConfig types sits ahead of this branch, so the two do not interfere.
Note: #4899 appears to be a byte-identical duplicate of #4894 (same title, same body, same author), so this PR fixes both.
Verification
Reproduced on current main before the fix (valid and malformed JSON string Content both produced the identical spurious message), then verified after the fix via
cfn-linton template files:{bad json, unclosed[):E3051 Document is not validwith the actual parser message, distinct from the old generic message{"schemaVersion":}): real enum validation error from inside the documentTests added in
test/unit/rules/resources/ssm/test_document.py, usingstr_nodeto cover the real template path (plainstrinputs already worked, which is why the existing tests did not catch this):str_node: no findingstr_node: real defect message, not the generic parser messagestr_node: inner schema validation runsdict_node: unchangedTest results:
test_document.py10 passed;test/unit/rules/resources/1355 passed;test/unit/rules/2082 passed;test/unit/module/decode/16 passed. The new string-content test fails on the pre-fix code, confirming it covers the regression.