File tree Expand file tree Collapse file tree
airbyte_cdk/sources/declarative/interpolation
unit_tests/sources/declarative/interpolation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,8 +124,8 @@ def eval(
124124
125125 def _literal_eval (self , result : Optional [str ], valid_types : Optional [Tuple [Type [Any ]]]) -> Any :
126126 try :
127- evaluated = ast .literal_eval (result ) # type: ignore # literal_eval is able to handle None
128- except (ValueError , SyntaxError ):
127+ evaluated = ast .literal_eval (result ) # type: ignore # result may be None; on error we return it unchanged
128+ except (ValueError , SyntaxError , TypeError ):
129129 return result
130130 if (not valid_types and not isinstance (evaluated , complex )) or (
131131 valid_types and isinstance (evaluated , valid_types )
Original file line number Diff line number Diff line change @@ -345,6 +345,16 @@ def test_interpolation_private_partition_attribute():
345345 assert actual_output == expected_output
346346
347347
348+ def test_literal_eval_handles_unhashable_set_typeerror ():
349+ """Test that _literal_eval gracefully handles TypeError from ast.literal_eval for nested sets."""
350+ # ast.literal_eval("{{'web'}, {'discover'}}") raises TypeError: unhashable type: 'set'
351+ # The interpolation should return the string as-is instead of propagating the error.
352+ config = {"query" : "{{'web'}, {'discover'}}" }
353+ s = "{{ config['query'] }}"
354+ val = interpolation .eval (s , config )
355+ assert val == "{{'web'}, {'discover'}}"
356+
357+
348358def test_given_complex_when_eval_then_return_string ():
349359 s = "9173710294242221J"
350360 config = {}
You can’t perform that action at this time.
0 commit comments