fix(provider): type auth errors (#27301)

This commit is contained in:
Shoubhit Dash
2026-05-13 15:47:13 +05:30
committed by GitHub
parent 733bd3c74e
commit 809af5c590
6 changed files with 200 additions and 32 deletions
@@ -10,6 +10,26 @@ import { described } from "./metadata"
const root = "/provider"
const ProviderAuthErrorName = Schema.Union([
Schema.Literal("BadRequest"),
Schema.Literal("ProviderAuthOauthMissing"),
Schema.Literal("ProviderAuthOauthCodeMissing"),
Schema.Literal("ProviderAuthOauthCallbackFailed"),
Schema.Literal("ProviderAuthValidationFailed"),
])
export class ProviderAuthApiError extends Schema.ErrorClass<ProviderAuthApiError>("ProviderAuthError")(
{
name: ProviderAuthErrorName,
data: Schema.Struct({
providerID: Schema.optional(ProviderID),
field: Schema.optional(Schema.String),
message: Schema.optional(Schema.String),
kind: Schema.optional(Schema.String),
}),
},
{ httpApiStatus: 400 },
) {}
export const ProviderApi = HttpApi.make("provider")
.add(
HttpApiGroup.make("provider")
@@ -39,7 +59,7 @@ export const ProviderApi = HttpApi.make("provider")
query: WorkspaceRoutingQuery,
payload: ProviderAuth.AuthorizeInput,
success: described(Schema.UndefinedOr(ProviderAuth.Authorization), "Authorization URL and method"),
error: HttpApiError.BadRequest,
error: ProviderAuthApiError,
}).annotateMerge(
OpenApi.annotations({
identifier: "provider.oauth.authorize",
@@ -52,7 +72,7 @@ export const ProviderApi = HttpApi.make("provider")
query: WorkspaceRoutingQuery,
payload: ProviderAuth.CallbackInput,
success: described(Schema.Boolean, "OAuth callback processed successfully"),
error: HttpApiError.BadRequest,
error: ProviderAuthApiError,
}).annotateMerge(
OpenApi.annotations({
identifier: "provider.oauth.callback",