Skip to content

Commit 6a56a9d

Browse files
committed
Add sanity check before trying to load JSON at key
Avoid verbose exception logging when not necessary.
1 parent 023423d commit 6a56a9d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

localstack_snapshot/snapshots/transformer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def _transform(self, input_data: Any, ctx: TransformContext = None) -> Any:
415415

416416
def _transform_dict(self, input_data: dict, ctx: TransformContext = None) -> dict:
417417
for k, v in input_data.items():
418-
if k == self.key and isinstance(v, str):
418+
if k == self.key and isinstance(v, str) and v.strip().startswith(("{", "[")):
419419
try:
420420
SNAPSHOT_LOGGER.debug(f"Replacing string value of {k} with parsed JSON")
421421
json_value = json.loads(v)

0 commit comments

Comments
 (0)