Skip to content

Commit 03225f1

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 <aj@airbyte.io>
1 parent d558466 commit 03225f1

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

airbyte/_util/api_util.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ def get_definition_id_for_connector_builder_project(
12031203
api_root: str,
12041204
client_id: SecretString,
12051205
client_secret: SecretString,
1206-
) -> str | None:
1206+
) -> str:
12071207
"""Get the source definition ID for a connector builder project.
12081208
12091209
Uses the Config API endpoint:
@@ -1219,7 +1219,10 @@ def get_definition_id_for_connector_builder_project(
12191219
client_secret: OAuth client secret
12201220
12211221
Returns:
1222-
The source definition ID if found, None otherwise (can be null in API response)
1222+
The source definition ID
1223+
1224+
Raises:
1225+
AirbyteError: If no definition is found for the given builder project ID
12231226
"""
12241227
json_result = _make_config_api_request(
12251228
path="/connector_builder_projects/get_with_manifest",
@@ -1231,4 +1234,13 @@ def get_definition_id_for_connector_builder_project(
12311234
client_id=client_id,
12321235
client_secret=client_secret,
12331236
)
1234-
return json_result.get("sourceDefinitionId")
1237+
definition_id = json_result.get("sourceDefinitionId")
1238+
if definition_id is None:
1239+
raise AirbyteError(
1240+
message="No source definition found for the given connector builder project",
1241+
context={
1242+
"workspace_id": workspace_id,
1243+
"builder_project_id": builder_project_id,
1244+
},
1245+
)
1246+
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)