Skip to content

Commit

Permalink
front connectors permissions error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
spolu committed Jan 2, 2025
1 parent 0313b5b commit 044cc1d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion connectors/src/api/get_connector_permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const _getConnectorPermissions = async (
return apiError(req, res, {
status_code: 401,
api_error: {
type: "connector_oauth_error",
type: "connector_authorization_error",
message: pRes.error.message,
},
});
Expand Down
7 changes: 6 additions & 1 deletion front/lib/api/data_source_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ async function getContentNodesForManagedDataSourceView(
});

if (connectorsRes.isErr()) {
if (connectorsRes.error.type === "connector_rate_limit_error") {
if (
[
"connector_rate_limit_error",
"connector_authorization_error",
].includes(connectorsRes.error.type)
) {
return new Err(new Error(connectorsRes.error.message));
}
return new Err(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,18 @@ export async function getManagedDataSourcePermissionsHandler(
},
});
}
if (permissionsRes.error.type === "connector_authorization_error") {
return apiError(req, res, {
status_code: 401,
api_error: {
type: "data_source_auth_error",
message:
"Authorization error while retrieving the data source permissions.",
},
});
}
// Other error codes are invalid requests from front to connectors or 500s which should be
// treated as 500.
return apiError(req, res, {
status_code: 500,
api_error: {
Expand Down
1 change: 1 addition & 0 deletions types/src/connectors/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type ConnectorsAPIErrorType =
| "connector_update_unauthorized"
| "connector_oauth_target_mismatch"
| "connector_oauth_error"
| "connector_authorization_error"
| "slack_channel_not_found"
| "connector_rate_limit_error"
| "slack_configuration_not_found"
Expand Down

0 comments on commit 044cc1d

Please sign in to comment.