Skip to content

Commit 08f7377

Browse files
fix: add validation to ensure Raw Files parser is only used with Copy Raw Files delivery method
Co-Authored-By: Aaron <AJ> Steers <[email protected]>
1 parent 3452003 commit 08f7377

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

airbyte_cdk/sources/file_based/file_types/raw_parser.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,20 @@ def parser_max_n_files_for_parsability(self) -> Optional[int]:
3737

3838
def check_config(self, config: FileBasedStreamConfig) -> Tuple[bool, Optional[str]]:
3939
"""
40-
Verify that this parser is only used with the "Raw Files" format.
41-
The validation that this format is only used with "Copy Raw Files" delivery method
42-
will be handled at a higher level in the availability strategy.
40+
Verify that this parser is only used with the "Copy Raw Files" delivery method.
4341
"""
42+
from airbyte_cdk.sources.file_based.config.abstract_file_based_spec import AbstractFileBasedSpec
43+
from airbyte_cdk.sources.file_based.config.validate_config_transfer_modes import use_file_transfer
44+
45+
# Create a mock config to check if the delivery method is set to use file transfer
46+
mock_config = type('MockConfig', (AbstractFileBasedSpec,), {
47+
'delivery_method': config.source_config.delivery_method,
48+
'documentation_url': staticmethod(lambda: ""),
49+
})()
50+
51+
if not use_file_transfer(mock_config):
52+
return False, "The 'Raw Files' parser can only be used with the 'Copy Raw Files' delivery method."
53+
4454
return True, None
4555

4656
async def infer_schema(

0 commit comments

Comments
 (0)