Skip to content

Commit 475d109

Browse files
fix: Fix lint and raise error when builder_project not found
- Fix line length issue in docstring (E501) - Changed get_definition_id_for_connector_builder_project to raise AirbyteError instead of returning None when definition not found - Simplified caller code in get_custom_source_definition to remove None check since API function now raises directly Fixes lint error and addresses feedback from @aaronsteers Co-Authored-By: AJ Steers <[email protected]>
1 parent e0af59c commit 475d109

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

airbyte/_util/api_util.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ def get_definition_id_for_connector_builder_project(
14271427
api_root: str,
14281428
client_id: SecretString,
14291429
client_secret: SecretString,
1430-
) -> str | None:
1430+
) -> str:
14311431
"""Get the source definition ID for a connector builder project.
14321432
14331433
Uses the Config API endpoint:
@@ -1443,7 +1443,10 @@ def get_definition_id_for_connector_builder_project(
14431443
client_secret: OAuth client secret
14441444
14451445
Returns:
1446-
The source definition ID if found, None otherwise (can be null in API response)
1446+
The source definition ID
1447+
1448+
Raises:
1449+
AirbyteError: If no definition is found for the given builder project ID
14471450
"""
14481451
json_result = _make_config_api_request(
14491452
path="/connector_builder_projects/get_with_manifest",
@@ -1455,4 +1458,13 @@ def get_definition_id_for_connector_builder_project(
14551458
client_id=client_id,
14561459
client_secret=client_secret,
14571460
)
1458-
return json_result.get("sourceDefinitionId")
1461+
definition_id = json_result.get("sourceDefinitionId")
1462+
if definition_id is None:
1463+
raise AirbyteError(
1464+
message="No source definition found for the given connector builder project",
1465+
context={
1466+
"workspace_id": workspace_id,
1467+
"builder_project_id": builder_project_id,
1468+
},
1469+
)
1470+
return definition_id

airbyte/cloud/workspaces.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -591,10 +591,11 @@ def get_custom_source_definition(
591591
"""Get a specific custom source definition by ID or builder project ID.
592592
593593
Args:
594-
definition_id: The definition ID. Mutually exclusive with `connector_builder_project_id`.
594+
definition_id: The definition ID. Mutually exclusive with
595+
`connector_builder_project_id`.
595596
definition_type: Connector type ("yaml" or "docker"). Required.
596-
connector_builder_project_id: The connector builder project ID. Mutually exclusive with
597-
`definition_id`.
597+
connector_builder_project_id: The connector builder project ID.
598+
Mutually exclusive with `definition_id`
598599
599600
Returns:
600601
CustomCloudSourceDefinition object
@@ -643,18 +644,6 @@ def get_custom_source_definition(
643644
client_secret=self.client_secret,
644645
)
645646

646-
if definition_id is None:
647-
raise exc.AirbyteError(
648-
message=(
649-
"No custom source definition found with the given "
650-
"connector_builder_project_id"
651-
),
652-
context={
653-
"workspace_id": self.workspace_id,
654-
"connector_builder_project_id": connector_builder_project_id,
655-
},
656-
)
657-
658647
result = api_util.get_custom_yaml_source_definition(
659648
workspace_id=self.workspace_id,
660649
definition_id=definition_id,

0 commit comments

Comments
 (0)