@@ -45,7 +45,7 @@ def __init__(self) -> None:
4545def _hash_text (input_text : str , hash_type : str = "md5" ) -> str :
4646 """Return the hash of the input text using the specified hash type."""
4747 if not input_text :
48- raise ValueError ("Input text cannot be empty." )
48+ raise ValueError ("Hash input text cannot be empty." )
4949
5050 hash_object = CHECKSUM_FUNCTIONS [hash_type ]()
5151 hash_object .update (input_text .encode ())
@@ -68,6 +68,10 @@ def validate_python_code(
6868
6969 Currently we fail if no checksums are provided, although this may change in the future.
7070 """
71+ if not code_text :
72+ # No code provided, nothing to validate.
73+ return
74+
7175 if not checksums :
7276 raise ValueError (f"A checksum is required to validate the code. Received: { checksums } " )
7377
@@ -77,8 +81,18 @@ def validate_python_code(
7781 f"Unsupported checksum type: { checksum_type } . Supported checksum types are: { CHECKSUM_FUNCTIONS .keys ()} "
7882 )
7983
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+ )
8296
8397
8498def get_registered_components_module (
@@ -94,7 +108,7 @@ def get_registered_components_module(
94108
95109 Returns `None` if no components is provided and the `components` module is not found.
96110 """
97- if config and INJECTED_COMPONENTS_PY in config :
111+ if config and config . get ( INJECTED_COMPONENTS_PY , None ) :
98112 if not custom_code_execution_permitted ():
99113 raise AirbyteCustomCodeNotPermittedError
100114
0 commit comments