fix(integrations): connect vercel when the code exchange omits user_id

Open
#799 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

Read src/lib/adapters/vercel/schemas.ts and src/lib/adapters/vercel/index.ts, then check a real code exchange for team and Hobby installs using the integration registered under #88. Update the schema, credential handling, tests and fixtures, and docs/providers/vercel.md based on the observed responses. Done when the acceptance criteria pass and the listed typecheck, lint and adapter tests succeed.

Written by the indexing model from the issue text.

Description

area: integrations bug impact: high priority: P1 size: S

Context

Found while re-reading Vercel's token documentation for #757 on 2026-12-02.

StackDash requires user_id in the code exchange response (TokenResponseSchema, src/lib/adapters/vercel/schemas.ts) and in the stored credential metadata (readScope, src/lib/adapters/vercel/index.ts), and a Hobby account is identified by it (listAccounts, sync, and webhook routing by payload.user.id).

Both Vercel documentation pages still show user_id in the code exchange response and in the client credentials response (Building Integrations with Vercel REST API, "Exchange code for Access Token"; Migrating to Short-Lived Access Tokens, "Request a short-lived token"). Vercel's own reference integration does not rely on it: vercel/example-marketplace-integration commit a06457a4 ("Renew installation access tokens (#147)", 2026-11-07) made user_id optional in its code exchange schema (lib/vercel/external-api.ts, test "accepts authorization-code responses with an optional legacy user ID"), and its README says the "Authorization-code exchange accepts the new expires_in response and optional user_id field".

Impact if Vercel omits it for an integration that issues short-lived tokens: every Vercel connect fails at the code exchange with invalid_response, so no Vercel account can connect on the integration #88 registers. Unverified until that integration exists.

Plan

  1. Check a real code exchange on the integration registered under #88 (development integration first): does the response carry user_id, for a team install and for a Hobby install?
  2. If it can be missing: make user_id optional in the code exchange schema. A team install does not need it (the account is team_id). For a Hobby install, take it from the client credentials response exchangeCode requests right after the exchange (#757), which the documentation shows with user_id, and refuse the connection with a clear error only when neither carries one.
  3. Keep readScope working for credentials stored before the change.

Acceptance criteria

  • A team install whose code exchange response has no user_id connects and syncs.
  • A Hobby install with no user_id in either response is refused with invalid_response, never stored half-identified.
  • docs/providers/vercel.md states what was observed and removes the Unverified entry.
  • Playwright e2e: not needed, the simulated Vercel flow does not call the token endpoint.

Files and areas

src/lib/adapters/vercel/index.ts, src/lib/adapters/vercel/schemas.ts, their tests and fixtures, docs/providers/vercel.md.

Non-goals: token renewal itself (#757), the integration registration (#88).

Verification

npm run typecheck, npm run lint, npx vitest run src/lib/adapters/vercel.


Branch: <issue-number>-vercel-optional-user-id

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

Dominant language
TypeScript
Stars
13
Forks
2
Avg merge
5h 20m
Merged PRs (30d)
287

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from eddiejaoude/StackDash

All issues in eddiejaoude/StackDash

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.