@@ -45,7 +45,7 @@ def __init__(self) -> None:
45
45
def _hash_text (input_text : str , hash_type : str = "md5" ) -> str :
46
46
"""Return the hash of the input text using the specified hash type."""
47
47
if not input_text :
48
- raise ValueError ("Input text cannot be empty." )
48
+ raise ValueError ("Hash input text cannot be empty." )
49
49
50
50
hash_object = CHECKSUM_FUNCTIONS [hash_type ]()
51
51
hash_object .update (input_text .encode ())
@@ -68,6 +68,10 @@ def validate_python_code(
68
68
69
69
Currently we fail if no checksums are provided, although this may change in the future.
70
70
"""
71
+ if not code_text :
72
+ # No code provided, nothing to validate.
73
+ return
74
+
71
75
if not checksums :
72
76
raise ValueError (f"A checksum is required to validate the code. Received: { checksums } " )
73
77
@@ -77,8 +81,18 @@ def validate_python_code(
77
81
f"Unsupported checksum type: { checksum_type } . Supported checksum types are: { CHECKSUM_FUNCTIONS .keys ()} "
78
82
)
79
83
80
- if _hash_text (code_text , checksum_type ) != checksum :
81
- raise AirbyteCodeTamperedError (f"{ checksum_type } checksum does not match." )
84
+ calculated_checksum = _hash_text (code_text , checksum_type )
85
+ if calculated_checksum != checksum :
86
+ raise AirbyteCodeTamperedError (
87
+ f"{ checksum_type } checksum does not match."
88
+ + str (
89
+ {
90
+ "expected_checksum" : checksum ,
91
+ "actual_checksum" : calculated_checksum ,
92
+ "code_text" : code_text ,
93
+ }
94
+ ),
95
+ )
82
96
83
97
84
98
def get_registered_components_module (
@@ -94,7 +108,7 @@ def get_registered_components_module(
94
108
95
109
Returns `None` if no components is provided and the `components` module is not found.
96
110
"""
97
- if config and INJECTED_COMPONENTS_PY in config :
111
+ if config and config . get ( INJECTED_COMPONENTS_PY , None ) :
98
112
if not custom_code_execution_permitted ():
99
113
raise AirbyteCustomCodeNotPermittedError
100
114
0 commit comments