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

オープン
#761 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
nextjs, react, supabase, typescript

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
13
フォーク
2
平均マージ
5時間 20分
マージ済み PR(30日)
287

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

eddiejaoude/StackDash のほかの issue

eddiejaoude/StackDash の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。