fix(jobs): keep a connection syncing when one of its accounts cannot be read

Abierto
#761 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
nextjs, react, supabase, typescript

Línea de trabajo

Read src/lib/jobs/sync-connection.ts and its account loop, then trace the reconnect flow in src/lib/connections/connect.ts and the adapter errors named in the issue. The work spans account level persistence, several adapters, GitHub installation checks, the connection page, and unit and Playwright tests. Done means the listed acceptance criteria pass, including the specified typecheck, lint, database tests, and connections end to end spec.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area: connections area: jobs bug impact: medium priority: P1 size: M

Context

Do after #760: it changes the same loop in src/lib/jobs/sync-connection.ts.

Found by the Fable pre-production review on 2026-12-02 (main at cedc1914; every line reference below re-checked on main at cde5aa3b). Source: provider connect readiness report, N5.

One account that cannot be read stops every account on its connection:

  • The account loop has no per-account handling (src/lib/jobs/sync-connection.ts:206-288): any throw goes to handleFailure for the whole connection (:113-114).
  • A 404 is invalid_response (src/lib/adapters/errors.ts:164), which a deleted Supabase project hits on its first request (src/lib/adapters/supabase/index.ts:826-834).
  • An account the credential no longer covers throws a plain Error (src/lib/adapters/vercel/index.ts:1025, src/lib/adapters/stripe/index.ts:1096, src/lib/adapters/digitalocean/index.ts:1329), which counts as internal_error (sync-connection.ts:386) and is retried every hour.
  • A reconnect upserts the accounts the new grant lists and never retires the rest (src/lib/connections/connect.ts:184-196), so an account the grant dropped stays included.
  • GitHub's sync never checks that the account belongs to the installation it mints a token for (src/lib/adapters/github/index.ts:475-495), so after a reconnect that grants another installation, the new account's figures can be stored under the old account.

Impact: one deleted Supabase project, an unshared Railway workspace, or a reconnect that grants another team stops the whole connection, with "did not answer" copy that points at the provider (sync-connection.ts:357). Every other account on it goes stale. #529 covers the simulated case only.

Plan

  1. Catch an account's failure inside the loop: record it on that account (a new external_accounts column for the last error code and reference), log it with a reference, and continue with the next account.
  2. Fail the connection only when every account failed, or when the error is connection wide (auth_revoked, permission_missing, rate limit).
  3. On reconnect, mark an included account the new grant no longer lists as not covered (skip it in sync, show it on the page) instead of leaving it included.
  4. Replace the plain Errors for an uncovered account with a typed adapter error, so it is classified as "account not covered", not internal_error.
  5. GitHub: refuse an externalAccountId that is not the installation's account before minting a token.
  6. The connection page names a failing or uncovered account and what to do.

Acceptance criteria

  • A failing account is named on the connection page with a reference, and the other accounts still sync (unit test).
  • After a reconnect, an included account the grant no longer lists is skipped and marked on the page (unit test).
  • GitHub refuses an account id that is not its installation's (unit test).
  • The Vercel, Stripe, and DigitalOcean "not covered" errors are typed and not retried as internal_error.
  • Playwright e2e covers the connection page notice, with an axe scan and a keyboard pass.

Files and areas

src/lib/jobs/sync-connection.ts, src/lib/connections/connect.ts, src/lib/adapters/errors.ts, the three adapters named above, src/lib/adapters/github/index.ts, a migration for the account level error, src/app/w/[workspace]/connections/[connectionId]/page.tsx, their tests.

Non-goals: the sync deadline (#{n4}), the connection level failure copy (separate issue), simulated reconnects (#529).

Verification

npm run typecheck, npm run lint, npx vitest run src/lib/jobs src/lib/connections src/lib/adapters, npm run test:db, the connections e2e spec.


Branch: <issue-number>-account-failure-isolation

Model: anthropic/claude-opus-5-5 | Reasoning effort: unknown

Lenguaje dominante
TypeScript
Estrellas
13
Forks
2
Merge medio
5 h 20 min
PR fusionados (30 d)
287

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de eddiejaoude/StackDash

Todos los issues de eddiejaoude/StackDash

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.