diff --git a/apps/backend/src/app/api/v1/integrations/neon/oauth/idp/[[...route]]/idp.ts b/apps/backend/src/app/api/v1/integrations/neon/oauth/idp/[[...route]]/idp.ts index 51c6a60f2..0cdf2bab6 100644 --- a/apps/backend/src/app/api/v1/integrations/neon/oauth/idp/[[...route]]/idp.ts +++ b/apps/backend/src/app/api/v1/integrations/neon/oauth/idp/[[...route]]/idp.ts @@ -48,9 +48,14 @@ function createAdapter(options: { } async upsert(id: string, payload: AdapterPayload, expiresInSeconds: number): Promise { - if (expiresInSeconds < 0) throw new StackAssertionError(`expiresInSeconds must be non-negative, got ${expiresInSeconds}`, { expiresInSeconds, model: this.model, id, payload }); - if (expiresInSeconds > 60 * 60 * 24 * 365 * 100) throw new StackAssertionError(`expiresInSeconds must be less than 100 years, got ${expiresInSeconds}`, { expiresInSeconds, model: this.model, id, payload }); - if (!Number.isFinite(expiresInSeconds)) throw new StackAssertionError(`expiresInSeconds must be a finite number, got ${expiresInSeconds}`, { expiresInSeconds, model: this.model, id, payload }); + try { + if (expiresInSeconds < 0) throw new StackAssertionError(`expiresInSeconds of ${this.model}:${id} must be non-negative, got ${expiresInSeconds}`, { expiresInSeconds, model: this.model, id, payload }); + if (expiresInSeconds > 60 * 60 * 24 * 365 * 100) throw new StackAssertionError(`expiresInSeconds of ${this.model}:${id} must be less than 100 years, got ${expiresInSeconds}`, { expiresInSeconds, model: this.model, id, payload }); + if (!Number.isFinite(expiresInSeconds)) throw new StackAssertionError(`expiresInSeconds of ${this.model}:${id} must be a finite number, got ${expiresInSeconds}`, { expiresInSeconds, model: this.model, id, payload }); + } catch (err) { + captureError('idp-adapter-upsert-assertion-error', err); + expiresInSeconds = 60 * 60 * 60 * 24; + } await niceUpdate(this.model, id, () => ({ payload, expiresAt: new Date(Date.now() + expiresInSeconds * 1000) })); } @@ -220,10 +225,10 @@ export async function createOidcProvider(options: { id: string, baseUrl: string captureError('idp-oidc-provider-server-error', err); }); - function middleware(middleware: Parameters[0]) { + function middleware(mw: Parameters[0]) { oidc.use((ctx, next) => { try { - return middleware(ctx, next); + return mw(ctx, next); } catch (err) { captureError('idp-oidc-provider-middleware-error', err); throw err;