Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plan renderer: ensure JSON strings are completely JSON #34959

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

liamcervante
Copy link
Member

Don't merge (or at least backport) this until after the release of 1.8.0 has been completed this week.

In #34702 we modified the JSON parsing of the plan renderer to support large (> 2^64) numbers. In doing so we changed the parsing to use the json.Decoder. The Decoder accepts partial JSON strings, so this means that a string that starts with a valid JSON object and then ends with a non-JSON piece of text is interpreted as valid JSON.

This PR updates the renderer so it checks the decoder has consumed the complete string before trusting that the returned object can be rendered as JSON.

In Martin's comments, he details how the ctyjson package supports this and the large number parsing by default. Unfortunately, we can't use the ctyjson package here as the renderer doesn't handle cty.Value objects instead just relying on the raw JSON objects that are available from the jsonplan package.

Fixes #34954

Target Version

v1.8.1

Proposed CHANGELOG

BUG FIXES

  • plan renderer: Correctly render strings that begin with JSON compatible text but don't end with it.

@liamcervante liamcervante added the 1.8-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label Apr 8, 2024
@liamcervante liamcervante requested a review from a team April 8, 2024 09:35
@liamcervante liamcervante merged commit 924958b into main Apr 11, 2024
6 checks passed
@liamcervante liamcervante deleted the liamcervante/34954 branch April 11, 2024 15:49
Copy link
Contributor

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1.8-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged
Projects
None yet
2 participants