File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33## Unreleased
44- DynamoDB CDC: Fix ` MODIFY ` operation by propagating ` NewImage ` fully
5+ - Zyp/Moksha: Improve error reporting when rule evaluation fails
56
67## 2024/09/25 v0.0.18
78- MongoDB: Improved ` MongoDBCrateDBConverter.decode_canonical ` to also
Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ def apply(self, data: t.Any) -> t.Any:
7878 data = rule .evaluate (data )
7979 except Exception :
8080 logger .exception (f"Error evaluating rule: { rule } " )
81+ if isinstance (data , map ):
82+ data = list (data )
8183 logger .debug (f"Error payload:\n { data } " )
8284 raise
8385 return data
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ def test_moksha_transformation_success_jq():
4949 assert moksha .apply (4242 ) == 42.42
5050
5151
52- def test_moksha_transformation_error_jq (caplog ):
52+ def test_moksha_transformation_error_jq_scalar (caplog ):
5353 moksha = MokshaTransformation ().jq (". /= 100" )
5454 with pytest .raises (ValueError ) as ex :
5555 moksha .apply ("foo" )
@@ -59,6 +59,16 @@ def test_moksha_transformation_error_jq(caplog):
5959 assert "Error payload:\n foo" in caplog .messages
6060
6161
62+ def test_moksha_transformation_error_jq_map (caplog ):
63+ moksha = MokshaTransformation ().jq (".foo" )
64+ with pytest .raises (ValueError ) as ex :
65+ moksha .apply (map (lambda x : x , ["foo" ])) # noqa: C417
66+ assert ex .match (re .escape ('Cannot index array with string "foo"' ))
67+
68+ assert "Error evaluating rule: MokshaRuntimeRule(type='jq'" in caplog .text
69+ assert "Error payload:\n []" in caplog .messages
70+
71+
6272def test_moksha_transformation_empty ():
6373 """
6474 Empty JSON Pointer expression means "root node".
You can’t perform that action at this time.
0 commit comments