Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
cdd1ac9
feat: skip config validation during discovery for sources with Dynami…
devin-ai-integration[bot] Apr 8, 2025
7490ad1
style: fix formatting issues
devin-ai-integration[bot] Apr 8, 2025
9e84e1c
fix: update entrypoint to make --config optional for discovery
devin-ai-integration[bot] Apr 8, 2025
47bd67c
style: fix formatting issues
devin-ai-integration[bot] Apr 8, 2025
36d7f1f
fix: add type annotation for empty_config
devin-ai-integration[bot] Apr 8, 2025
b002218
refactor: use generator comprehension instead of list comprehension
devin-ai-integration[bot] Apr 8, 2025
acbab7e
Update airbyte_cdk/entrypoint.py
aaronsteers Apr 8, 2025
d33dcdd
Update CHANGELOG.md
aaronsteers Apr 8, 2025
4253f28
Update airbyte_cdk/sources/declarative/manifest_declarative_source.py
aaronsteers Apr 8, 2025
64610b9
feat: add check_config_during_discover flag for targeted config valid…
devin-ai-integration[bot] Apr 8, 2025
b228857
style: fix formatting issues
devin-ai-integration[bot] Apr 8, 2025
77772c3
Update CHANGELOG.md
aaronsteers Apr 8, 2025
6ca213c
refactor: push check_config_during_discover flag into connector base …
devin-ai-integration[bot] Apr 8, 2025
dce4f8c
style: fix formatting issues
devin-ai-integration[bot] Apr 8, 2025
24a0919
fix: resolve MyPy type checking issues with check_config_during_disco…
devin-ai-integration[bot] Apr 9, 2025
f920f04
refactor: move check_config_during_discover to BaseConnector class
devin-ai-integration[bot] Apr 9, 2025
f01525f
Update airbyte_cdk/connector.py
aaronsteers Apr 9, 2025
769d361
Update airbyte_cdk/connector.py
aaronsteers Apr 9, 2025
c3cbad8
Update airbyte_cdk/sources/declarative/manifest_declarative_source.py
aaronsteers Apr 9, 2025
3cb8faf
Auto-fix lint and format issues
Apr 9, 2025
08397ad
fix condition direction
aaronsteers Apr 9, 2025
4066c75
fix direction of comparison
aaronsteers May 20, 2025
943ea41
Merge remote-tracking branch 'origin/main' into aj/feat/unprivileged-…
aaronsteers May 20, 2025
fac853c
fix config parse
aaronsteers May 20, 2025
9b37bc5
handle case of missing config
aaronsteers May 20, 2025
640c811
fix: don't assume bad config will fail discover
aaronsteers May 20, 2025
5894a1f
improve read check
aaronsteers May 20, 2025
a79ad83
quote the name
aaronsteers May 20, 2025
46170ad
Auto-fix lint and format issues
May 20, 2025
c8dd910
default to not checking before discover
aaronsteers May 20, 2025
2ce3b99
don't raise on missing error in helper function
aaronsteers May 20, 2025
dd94e86
improve tests
aaronsteers May 20, 2025
451ce82
Merge branch 'main' into aj/feat/unprivileged-discover-for-declarativ…
aaronsteers Jul 18, 2025
59353af
Auto-commit Resolving dependencies... changes
Jul 18, 2025
e58bdd3
Apply suggestion from @coderabbitai[bot]
aaronsteers Jul 18, 2025
bfaf62f
Apply suggestion from @coderabbitai[bot]
aaronsteers Jul 18, 2025
b1cd8af
Apply suggestion from @coderabbitai[bot]
aaronsteers Jul 18, 2025
f87c884
Apply suggestion from @coderabbitai[bot]
aaronsteers Jul 18, 2025
f3b6928
Apply suggestion from @coderabbitai[bot]
aaronsteers Jul 18, 2025
b956a30
Apply suggestion from @aaronsteers
aaronsteers Jul 18, 2025
6cf6e1c
fix: Add missing config parameter in _uses_dynamic_schema_loader method
devin-ai-integration[bot] Jul 18, 2025
49d571e
fix: Resolve MyPy error and update test plan with successful results
devin-ai-integration[bot] Jul 18, 2025
6319699
fix: Add missing blank line for ruff formatting compliance
devin-ai-integration[bot] Jul 18, 2025
3798fb4
fix: Resolve Pydantic frozen instance error in connector_base.py
devin-ai-integration[bot] Jul 18, 2025
ff14901
Apply suggestion from @aaronsteers
aaronsteers Jul 18, 2025
2345164
selective import from 'origin/devin/1752808596-manual-tests-static-sc…
aaronsteers Jul 18, 2025
3245f0f
catch up with changes on main
aaronsteers Jul 18, 2025
6748db0
add exception arg
aaronsteers Jul 18, 2025
e27697e
remove unused import
aaronsteers Jul 18, 2025
a1760e1
Merge main into aj/feat/unprivileged-discover-for-declarative-static-…
devin-ai-integration[bot] Oct 31, 2025
a69c252
fix: Update test imports to use legacy module location
devin-ai-integration[bot] Oct 31, 2025
7048b30
feat: Add unprivileged discover support for declarative sources with …
devin-ai-integration[bot] Oct 31, 2025
711635f
Potential fix for pull request finding 'Unused import'
aaronsteers Oct 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions airbyte_cdk/cli/source_declarative_manifest/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ def _parse_inputs_into_config_catalog_state(
]:
config = (
ConcurrentDeclarativeSource.read_config(parsed_args.config)
if hasattr(parsed_args, "config")
else None
if hasattr(parsed_args, "config") and parsed_args.config
else {}
)
catalog = (
ConcurrentDeclarativeSource.read_catalog(parsed_args.catalog)
Expand Down
9 changes: 8 additions & 1 deletion airbyte_cdk/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ def load_optional_package_file(package: str, filename: str) -> Optional[bytes]:


class BaseConnector(ABC, Generic[TConfig]):
# configure whether the `check_config_against_spec_or_exit()` needs to be called
check_config_against_spec: bool = True
"""Configure whether `check_config_against_spec_or_exit()` needs to be called."""

check_config_during_discover: bool = True
"""Determines whether config validation should be skipped during discovery.

By default, config validation is not skipped during discovery. This can be overridden
by sources that can provide catalog information without requiring authentication.
"""

@abstractmethod
def configure(self, config: Mapping[str, Any], temp_dir: str) -> TConfig:
Expand Down
34 changes: 28 additions & 6 deletions airbyte_cdk/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def parse_args(args: List[str]) -> argparse.Namespace:
)
required_discover_parser = discover_parser.add_argument_group("required named arguments")
required_discover_parser.add_argument(
"--config", type=str, required=True, help="path to the json configuration file"
"--config", type=str, required=False, help="path to the json configuration file"
)
discover_parser.add_argument(
"--manifest-path",
Expand Down Expand Up @@ -177,19 +177,41 @@ def run(self, parsed_args: argparse.Namespace) -> Iterable[str]:
)
if cmd == "spec":
message = AirbyteMessage(type=Type.SPEC, spec=source_spec)
yield from [
yield from (
self.airbyte_message_to_string(queued_message)
for queued_message in self._emit_queued_messages(self.source)
]
)
yield self.airbyte_message_to_string(message)
elif (
cmd == "discover"
and not parsed_args.config
and not self.source.check_config_during_discover
):
# Connector supports unprivileged discover
empty_config: dict[str, Any] = {}
yield from (
self.airbyte_message_to_string(queued_message)
for queued_message in self._emit_queued_messages(self.source)
)
yield from map(
AirbyteEntrypoint.airbyte_message_to_string,
self.discover(source_spec, empty_config),
)
elif parsed_args.config is None:
# Raise a helpful error message if we reach here with no config.
raise ValueError(
"The '--config' argument is required but was not provided. "
"This connector does not support unprivileged discovery. "
"Please provide a valid configuration file using the --config flag."
)
else:
raw_config = self.source.read_config(parsed_args.config)
config = self.source.configure(raw_config, temp_dir)

yield from [
yield from (
self.airbyte_message_to_string(queued_message)
for queued_message in self._emit_queued_messages(self.source)
]
)
if cmd == "check":
yield from map(
AirbyteEntrypoint.airbyte_message_to_string,
Expand Down Expand Up @@ -261,7 +283,7 @@ def discover(
self, source_spec: ConnectorSpecification, config: TConfig
) -> Iterable[AirbyteMessage]:
self.set_up_secret_filter(config, source_spec.connectionSpecification)
if self.source.check_config_against_spec:
if self.source.check_config_during_discover:
self.validate_connection(source_spec, config)
catalog = self.source.discover(self.logger, config)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def _get_declarative_component_schema() -> Dict[str, Any]:
class ManifestDeclarativeSource(DeclarativeSource):
"""Declarative source defined by a manifest of low-code components that define source connector behavior"""

check_config_during_discover: bool = False
"""Declarative sources default to not checking config before discovery."""

def __init__(
self,
source_config: ConnectionDefinition,
Expand Down Expand Up @@ -149,6 +152,7 @@ def __init__(
# apply additional post-processing to the manifest
self._post_process_manifest()

self.check_config_during_discover = self._uses_dynamic_schema_loader()
spec: Optional[Mapping[str, Any]] = self._source_config.get("spec")
self._spec_component: Optional[Spec] = (
self._constructor.create_component(SpecModel, spec, dict()) if spec else None
Expand Down Expand Up @@ -614,3 +618,37 @@ def _dynamic_stream_configs(

def _emit_manifest_debug_message(self, extra_args: dict[str, Any]) -> None:
self.logger.debug("declarative source created from manifest", extra=extra_args)

def _uses_dynamic_schema_loader(self) -> bool:
"""
Determines if any stream in the source uses a DynamicSchemaLoader.

DynamicSchemaLoader makes a separate call to retrieve schema information,
which might require authentication. When present, config validation cannot
be skipped during discovery.

Returns:
bool: True if any stream uses a DynamicSchemaLoader (config required for discover),
False otherwise (unprivileged discover may be supported).
"""
empty_config: Dict[str, Any] = {}
for stream_config in self._stream_configs(self._source_config, empty_config):
schema_loader = stream_config.get("schema_loader", {})
if (
isinstance(schema_loader, dict)
and schema_loader.get("type") == "DynamicSchemaLoader"
):
return True

dynamic_streams = self._source_config.get("dynamic_streams", [])
if dynamic_streams:
for dynamic_stream in dynamic_streams:
stream_template = dynamic_stream.get("stream_template", {})
schema_loader = stream_template.get("schema_loader", {})
if (
isinstance(schema_loader, dict)
and schema_loader.get("type") == "DynamicSchemaLoader"
):
return True

return False
35 changes: 35 additions & 0 deletions airbyte_cdk/sources/declarative/concurrent_declarative_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ def __init__(
message_repository=self._message_repository,
)

self.check_config_during_discover = self._uses_dynamic_schema_loader()

def _pre_process_manifest(self, manifest: Dict[str, Any]) -> Dict[str, Any]:
"""
Preprocesses the provided manifest dictionary by resolving any manifest references.
Expand Down Expand Up @@ -651,3 +653,36 @@ def _select_streams(
as_airbyte_message(configured_stream.stream, AirbyteStreamStatus.INCOMPLETE)
)
return abstract_streams

def _uses_dynamic_schema_loader(self) -> bool:
"""
Determines if any stream in the source uses a DynamicSchemaLoader.

DynamicSchemaLoader makes a separate call to retrieve schema information,
which might require authentication. When present, config validation cannot
be skipped during discovery.

Returns:
bool: True if any stream uses a DynamicSchemaLoader (config required for discover),
False otherwise (unprivileged discover may be supported).
"""
for stream_config in self._stream_configs(self._source_config):
schema_loader = stream_config.get("schema_loader", {})
if (
isinstance(schema_loader, dict)
and schema_loader.get("type") == "DynamicSchemaLoader"
):
return True

dynamic_stream_definitions = self._source_config.get("dynamic_streams", [])
if dynamic_stream_definitions:
for dynamic_definition in dynamic_stream_definitions:
stream_template = dynamic_definition.get("stream_template", {})
schema_loader = stream_template.get("schema_loader", {})
if (
isinstance(schema_loader, dict)
and schema_loader.get("type") == "DynamicSchemaLoader"
):
return True

return False
1 change: 0 additions & 1 deletion airbyte_cdk/test/entrypoint_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class AirbyteEntrypointException(Exception):
def __post_init__(self) -> None:
super().__init__(self.message)


class EntrypointOutput:
"""A class to encapsulate the output of an Airbyte connector's execution.

Expand Down
29 changes: 23 additions & 6 deletions airbyte_cdk/test/standard_tests/source_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ def test_discover(
) -> None:
"""Standard test for `discover`."""
if scenario.expected_outcome.expect_exception():
# If the scenario expects an exception, we can't ensure it specifically would fail
# in discover, because some discover implementations do not need to make a connection.
# We skip this test in that case.
pytest.skip("Skipping discover test for scenario that expects an exception.")
return
pytest.skip(
"Skipping `discover` test because the scenario is expected to raise an exception."
)

run_test_job(
self.create_connector(scenario),
Expand Down Expand Up @@ -111,6 +109,15 @@ def test_basic_read(
obtain the catalog of streams, and then it runs a `read` job to fetch
records from those streams.
"""
check_result: entrypoint_wrapper.EntrypointOutput = run_test_job(
self.create_connector(scenario),
"check",
test_scenario=scenario,
connector_root=self.get_connector_root_dir(),
)
if scenario.expected_outcome.expect_exception() and check_result.errors:
# Expected failure and we got it. Return early.
return
discover_result = run_test_job(
self.create_connector(scenario),
"discover",
Expand Down Expand Up @@ -144,7 +151,9 @@ def test_basic_read(
connector_root=self.get_connector_root_dir(),
catalog=configured_catalog,
)

if scenario.expected_outcome.expect_exception() and not result.errors:
# By now we should have raised an exception.
raise AssertionError("Expected an error but got none.")
if scenario.expected_outcome.expect_success() and not result.records:
raise AssertionError("Expected records but got none.")

Expand All @@ -153,6 +162,14 @@ def test_fail_read_with_bad_catalog(
scenario: ConnectorTestScenario,
) -> None:
"""Standard test for `read` when passed a bad catalog file."""
# Recreate the scenario with the same config but set the status to "failed".
scenario = ConnectorTestScenario(
config_dict=scenario.get_config_dict(
connector_root=self.get_connector_root_dir(),
empty_if_missing=False,
),
status="failed",
)
invalid_configured_catalog = ConfiguredAirbyteCatalog(
streams=[
# Create ConfiguredAirbyteStream which is deliberately invalid
Expand Down
Loading
Loading