feat(integrations): tell a vercel billing endpoint that is not enabled from a month with no costs

Abierto
#749 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
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
next.js, typescript

Línea de trabajo

Read the live vercel.billing.month_not_found logs from #748 first; the issue says they are needed to learn whether Vercel distinguishes the two 404 cases and how often the disabled endpoint occurs. Eddie must decide which option to pursue before implementation. If a change is chosen, start in src/lib/adapters/vercel/index.ts and its index.test.ts tests, then update docs/providers/vercel.md; done means tests cover both 404 meanings and a disabled endpoint produces the agreed billing error without spend readings.

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

Descripción

area: integrations decision enhancement impact: medium priority: P3 size: S

Context

Vercel documents one 404 on GET /v1/billing/charges for two cases: "The endpoint is not enabled for this team, or no billing costs exist for it in the requested range." The reference and https://vercel.com/openapi.json give it no content schema and no error code (both re-read 2026-12-02; jq '.paths["/v1/billing/charges"].get.responses["404"]' returns only that description).

Since #748 (issue #729), the month request's 404 reads as a month to date of 0 and is logged as vercel.billing.month_not_found with the body's error.code when it has one (src/lib/adapters/vercel/index.ts:518-534 at 4efb943e). A team whose billing endpoint is not enabled therefore shows four verified_spend readings of 0 on every hourly sync (pollIntervalSeconds: 3600, index.ts:922) and no billing:read partial error. First-sync past days are already protected: they are stated only when one of the two requests answered 200 (index.ts:580-596).

The Fable review of #748 (review 6149166937) raised a way to tell the two 404s apart, and said it should wait until the log line shows whether the case occurs at all. Whether to do it, and how, is Eddie's decision.

Option Pros Cons Effort Impact
Status quo: a month 404 reads as 0 and is logged (index.ts:518-534) No extra request. The log line and its error.code show whether the not-enabled case happens at all before anything is built A not-enabled team sees a verified $0 month to date with no notice for as long as the endpoint stays off; only the server log knows XS (nothing) A team owner on Pro or Enterprise whose billing endpoint is off reads $0 spend on the dashboard indefinitely; no data loss, and it self-corrects the first sync after Vercel answers 200
Wider-range probe: when the month answers 404, request up to one year back (the documented maximum range); a second 404 returns PermissionMissingError(["billing:read"]) instead of zeros Grounded in the docs alone; turns the silent $0 into the same missing-permission notice a 403 gives (index.ts:503-516) One extra request per hourly sync while the month is empty, against a per team rate limit whose numbers are undocumented (docs/providers/vercel.md:502). Rests on a Pro team having a Purchase row every billing period, which comes from the review and is not confirmed in Vercel's docs. A team with no charge in a whole year would show a false missing-permission notice S Same users as above get an honest notice instead of $0. Risk: a wrong notice for a team that really had no costs for a year, and rate limit pressure on the 1st of each month when every team's month is empty until its first billing day
Classify by error.code: once live logs show two distinct codes on vercel.billing.month_not_found, map the not-enabled code to the billing:read partial error Exact, and no extra request Depends on Vercel sending a code at all, which is undocumented; may never be possible. Needs live sync logs first XS once a code is seen; nothing can be built before Same users get an honest notice with no false positives, but only if Vercel's bodies differ

Files each option touches:

Option Files
Status quo none
Wider-range probe src/lib/adapters/vercel/index.ts (syncBilling, readCharges), src/lib/adapters/vercel/index.test.ts, docs/providers/vercel.md
Classify by error.code src/lib/adapters/vercel/index.ts (syncBilling), src/lib/adapters/vercel/index.test.ts, docs/providers/vercel.md

Recommendation: keep the status quo until live logs exist, then choose. The deciding argument: the vercel.billing.month_not_found line with its error.code is the only evidence that can show whether the not-enabled case occurs and whether the cheaper exact option is possible, and it ships with #748. Second choice: classify by error.code, if the logs show two codes; the wider-range probe only if they do not and the case is seen in practice.

Plan

  1. Wait for live syncs with #748 deployed and read vercel.billing.month_not_found lines: how often per team, and which error.code values appear.
  2. Eddie picks an option from the table above.
  3. Implement the chosen option in syncBilling with tests for both 404 meanings, and update the 404 bullet, the Unverified item, and the Sources entry in docs/providers/vercel.md.

Acceptance criteria

  • Eddie's decision is recorded on this issue with the reasons that decided it
  • If an option other than the status quo is chosen: a team whose billing endpoint is not enabled gets a billing:read partial error and no spend readings, and a team with no costs this month still gets a month to date of 0
  • Unit tests cover both readings of the month 404; no Playwright coverage needed, because no UI changes

Files and areas

src/lib/adapters/vercel/index.ts, src/lib/adapters/vercel/index.test.ts, docs/providers/vercel.md. Non-goals: the first-sync past-day rule (already settled in #748), any other provider, any change to the dashboard's handling of a partial error.

Verification

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


Branch: <issue-number>-vercel-billing-not-enabled
Closes with a Closes #<issue-number> footer on the commit or pull request.

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

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.