Skip to content

fix: preserve version strings with trailing zeros in JSON parsing#799

Open
AruneshDwivedi wants to merge 1 commit into
terraform-compliance:masterfrom
AruneshDwivedi:fix/version-string-truncation
Open

fix: preserve version strings with trailing zeros in JSON parsing#799
AruneshDwivedi wants to merge 1 commit into
terraform-compliance:masterfrom
AruneshDwivedi:fix/version-string-truncation

Conversation

@AruneshDwivedi

@AruneshDwivedi AruneshDwivedi commented Jun 9, 2026

Copy link
Copy Markdown

Version strings like "1.30" were being truncated to "1.3" because json.loads() converts them to floats, losing the trailing zero. This caused test failures when comparing version strings.

Fixed by checking if the string looks like a version number before passing it through json.loads(). If it matches a version pattern, keep it as a string.

Version strings like "1.30" were being truncated to "1.3" because
json.loads() converts them to floats, losing the trailing zero.

Changed json.loads(plan_lines) to json.loads(plan_lines, parse_float=str)
to preserve the original string representation of numeric values.

Fixes terraform-compliance#752

Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant