Skip to content

Call Vercel teams, projects, deployments and drains through the distilled SDK - #2858

Merged
Makisuo merged 3 commits into
mainfrom
t3/distilled-vercel
Nov 19, 2026
Merged

Makisuo merged 3 commits into
mainfrom
t3/distilled-vercel

Conversation

@Makisuo

@Makisuo Makisuo commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Stacked on #2857. Moves the Vercel integration's REST calls onto @distilled.cloud/vercel, through a small adapter that keeps our vendor HTTP rules, so later ports (Supabase, Railway, GCP) reuse it.

What changed

  • integrations/vendor-sdk.ts (new): runs one @distilled.cloud/* operation under the same rules as vendor-http:
    • a timeout per attempt, the body read included
    • transient retries (5xx, transport, timeout) for GET, PUT and DELETE only, so a drain create is sent once
    • one wait for a retry-after of 10s or less; a longer one fails at once as rate_limited with the wait
    • redirects refused with their status and location; the SDK alone would read a 3xx body as an answer
    • every failure as a VendorHttpError, with the vendor's message as detail, so each client's existing error mapping works unchanged
    • each body decoded with our own schema, since the SDK does not validate responses
  • vendor-http.ts: the retry rule moves out of make into an exported retryVendorCall, so the HTTP and SDK paths share one implementation. No behaviour change for existing clients.
  • vercel/api.ts: teams, projects, deployments, and drain create, update, list and delete go through the SDK. Billing charges stay on plain HTTP: Vercel streams them as JSONL, which the SDK reads as one JSON body.
  • Drain delivery is typed as the two shapes Maple sends (http, otlphttp), in place of an open record. The SDK's request type needs it, and it is a tighter contract.

Behaviour to know about

  • Paging: teams and deployments page only with a numeric until (all Vercel answers for them). A non-numeric next now ends the listing instead of being sent back as from. Projects still take either.
  • Error body: an SDK refusal carries Vercel's message but not the raw body (VendorHttpError.body); nothing reads body for Vercel.
  • Traces: each call gets the SDK's span, which records the path template, never the query string.

Traces and bundle

  • One Client span per attempt, none of the SDK's: each attempt runs in a VendorSdk.request Client span through vendorSdkRequestSpan (Read Anthropic costs and PlanetScale invoices through distilled SDKs #2857). It records host, path, method, status and error.type, never the query or the vendor's message, and only an unreadable answer fails it. A new test checks this and fails when the SDK's tracing is turned back on.
  • Worker build: @distilled.cloud/vercel is added to WORKER_PURE_OPTIONS.

Verification

  • vendor-sdk.test.ts (8 tests) drives a real SDK operation over a fake API: a read retried twice on a 502, a create sent once, a 302 refused with its status and location, a 403 keeping the vendor's message, a short retry-after waited out on a create, a long one failing at once with the wait, an unreadable 2xx, and a timeout. The redirect test fails when the refusal is removed.
  • The existing Vercel suite passes unchanged, including 403 messages, 404/410 deletes, 500/502 and a 30-minute Retry-After hold.
  • vitest over services/integrations, services/cost and services/security (every vendor-http client): 1,702 passed.
  • packages/backend typecheck: no errors. oxlint -c .oxlintrc.effect.json and oxfmt on every changed file: clean.

No UI change, so no screenshots.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Devin Review

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@maple-review-bot

This comment has been minimized.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

@maple-review-bot

This comment has been minimized.

Base automatically changed from t3/distilled-sdk-survey to main November 19, 2026 15:13
…h the distilled SDK

Adds vendor-sdk, which runs a @distilled.cloud operation under the
vendor-http rules: a timeout per attempt, transient retries for idempotent
calls only, one wait for a short retry-after, redirects refused with their
status, and every failure as a VendorHttpError. The retry rule moves out of
vendor-http's make into retryVendorCall, so both paths share it.

Vercel's teams, projects, deployments and drains go through it. The billing
charges stay on plain HTTP: the answer is a JSONL stream the SDK reads as one
JSON body. Drain delivery is now typed as the two shapes Maple sends.
The SDK's own span failed on every refusal with the vendor's message as its
cause. Each attempt now runs in a VendorSdk.request Client span through
vendorSdkRequestSpan: the SDK's tracing is off, a refusal lands as
error.type and the status, and only an unreadable answer fails the span.
The host and path the SDK sent to are recorded on it, never the query.

Also marks @distilled.cloud/vercel pure for the Worker build.
…atus

The SDKs hand back `{}` for an empty or `null` 2xx body, which a listing
schema with optional fields reads as an empty page: a sync would then
delete everything it had stored. The adapter now reads each answer off the
wire, so such a body reaches the schema as `null`, as vendor-http did.

It also records the status the vendor sent: the SDK's error classes stand
for more than one (408 and 504 are both GatewayTimeout).
@Makisuo
Makisuo force-pushed the t3/distilled-vercel branch from 47810fd to 264743b Compare November 19, 2026 15:15
@Makisuo
Makisuo merged commit 17b2359 into main Nov 19, 2026
7 checks passed
@Makisuo
Makisuo deleted the t3/distilled-vercel branch November 19, 2026 15:16
@maple-review-bot

maple-review-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Maple review

🟢 Confidence 9/10 · safe to merge. The adapter is small and pinned by eleven tests, but VendorSdk.paginate and the timestamp cursor remain untested on a path serving ~5.9k calls/day (open finding F1).
1 note · tests partial −1 · risk medium · 2/2 new units observable

Moves Vercel's teams, projects, deployments and drain calls onto @distilled.cloud/vercel behind a new VendorSdk adapter that keeps vendor-http's timeout, retry and redirect rules. The adapter reads correctly and I found no new defect; the earlier note that paginate is untested still stands.

  • VendorSdk runs one SDK operation per attempt under vendor-http's timeout, retry and no-redirect rules
  • retryVendorCall is extracted from VendorHttp.make so both transports share one retry rule
  • Teams, projects, deployments and drain create/update/list/delete go through the SDK; billing stays on plain HTTP
  • Teams and deployments now page only on a numeric until, ending on any other cursor

Still open from earlier reviews

264743b · What was checked, coverage and telemetry details are on the Maple / review check. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant