fix(terraform): handle null values and alternative blocks in plan parser for aws_batch_job_definition#7586
Open
AtlasWarden wants to merge 2 commits into
Open
Conversation
…_batch_job_definition blocks
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
This PR resolves an unhandled
TypeErrorcrash in the Terraform plan parser and expands policy scanning coverage foraws_batch_job_definitionconfigurations.The Problem
Currently,
RESOURCE_TYPES_JSONIFYmaps"aws_batch_job_definition"strictly to a single string attribute:"container_properties".ecs_properties,eks_properties, ornode_properties), Terraform sets the unused"container_properties"key tonullinside the generated plan JSON.jsonify()function evaluatesif jsonify_key in obj, which returnsTruebecause the key physically exists in the dictionary with anullvalue.null(PythonNone) directly intojson.loads(), causing an immediate framework crash:TypeError: the JSON object must be str, bytes or bytearray, not NoneType.The Solution
RESOURCE_TYPES_JSONIFYto allow a tuple of valid strings for a resource type to support multi-variant configurations.jsonify()to dynamically evaluate single string mappings or iterate through tuples seamlessly.if jsonify_key in obj and obj[jsonify_key]) to gracefully filter outnull,None, or empty arrays before parsing.Fixes # 7587
Checklist: