fix(integrations): keep a simulated connection's accounts on reconnect

Aperta
#529 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
next.js, playwright, react, typescript
Ambito
backend, testing

Direzione di ricerca

Start with src/lib/adapters/simulated/index.ts and trace how exchangeCode gets its seed during reconnect, then read the reconnect flow in src/app/api/dev/fake-provider/authorize/route.ts. Update the simulated webhook setup in src/lib/adapters/simulated/webhooks.ts and Polar twin in src/lib/adapters/simulated/polar.ts; run npx vitest run src/lib/adapters/simulated. Finish by covering the refusal path in e2e/webhook-setup-polar.spec.ts with the keyboard and verifying reconnect preserves the included accounts.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: integrations bug impact: low priority: P2 size: S

Context

Found while fixing the Fable review of #525 (Polar webhooks, #429).

A simulated provider's exchangeCode (src/lib/adapters/simulated/index.ts) mints a fresh seed for every grant ("A fresh seed per grant, so two simulated connections never share accounts or events"), and the twin's accounts are named after that seed (Polar's sim-org-<seed>). A reconnect, such as the write access consent of automatic webhook setup, is a new grant. So connect.ts upserts a second account with a new seed and leaves the first one included. Observed in an e2e run on #525: after the consent, the simulated Polar connection held sim-org-402df0db and sim-org-0f23f197, both included. The stale account no longer belongs to the grant, so the twin's sync refuses it ("Simulated has no such account").

The cost is concrete for #525. Polar's automatic setup needs a connection that includes exactly one organization (AutomaticWebhookSetup.accounts: "one"). Polar's twin therefore does not forward that limit (src/lib/adapters/simulated/polar.ts), or every simulated automatic setup would be refused after its own consent. The one-organization refusal is unit tested but cannot run end to end against the twin.

Plan

  1. Keep the seed on a reconnect of a simulated connection, for example by carrying the stored credential's seed through the reconnect state to the simulated consent screen and into the code exchangeCode reads.
  2. With the seed kept, forward accounts in simulatedConnectionSetup (src/lib/adapters/simulated/webhooks.ts), and drop the note in simulated/polar.ts.
  3. Add the one-organization refusal to e2e/webhook-setup-polar.spec.ts: seed a second included organization, choose automatic setup, and assert no consent screen and the refusal banner.

Acceptance criteria

  • Reconnecting a simulated connection leaves its accounts unchanged.
  • Polar's twin carries accounts: "one", and its automatic setup still succeeds after the consent.
  • Unit test for the reconnect seed; Playwright: the refusal path in e2e/webhook-setup-polar.spec.ts, with the keyboard.

Files and areas

  • src/lib/adapters/simulated/index.ts, src/lib/adapters/simulated/webhooks.ts, src/lib/adapters/simulated/polar.ts, src/app/api/dev/fake-provider/authorize/route.ts, e2e/webhook-setup-polar.spec.ts.
  • Non-goals: what a real provider's reconnect does with accounts it no longer lists.

Verification

  • npx vitest run src/lib/adapters/simulated
  • the Polar webhook setup spec through the guarded runner

Branch: <issue-number>-simulated-reconnect-seed
Closes with a Closes #<issue-number> footer on the commit or pull request.

Model: anthropic/claude-opus-5-5 | Reasoning effort: not reported by the harness

Lingua principale
TypeScript
Stelle
13
Fork
2
Merge medio
5h 20m
PR unite (30g)
287

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di eddiejaoude/StackDash

Tutte le issue di eddiejaoude/StackDash

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.