Skip to content

feat(prisma)!: type the RoutingUrl refusals, on the 2026-11-21 spec - #1348

Draft
wmadden wants to merge 13 commits into
alchemy-run:mainfrom
wmadden-electric:feat/prisma-routing-urls
Draft

wmadden wants to merge 13 commits into
alchemy-run:mainfrom
wmadden-electric:feat/prisma-routing-urls

Conversation

@wmadden

@wmadden wmadden commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

A caller of Prisma's RoutingUrl API could not tell from @distilled.cloud/prisma which refusal it got. Now it can:

import * as Prisma from "@distilled.cloud/prisma/management";

yield* Prisma.createServiceUrl({ serviceId, hostname: "api.example.com", logicalId: "api" }).pipe(
  Effect.catchTags({
    RoutingUrlQuotaExceeded: () => …,       // 409 quota-exceeded
    RoutingUrlLogicalIdTaken: () => …,      // 409 logical-id-taken
    RoutingUrlInvalidHostname: () => …,     // 422 invalid-hostname
    RoutingUrlServiceNotOnABranch: () => …, // 422 service-not-on-a-branch
  }),
);

alchemy-run/alchemy#3529 (Prisma.RoutingUrl, Prisma.DomainOwnership) is the caller, and depends on this.

The failing calls

Refusals told apart only by their message. POST /v1/services/{serviceId}/urls and PATCH /v1/urls/{id} answer five different refusals with 409 and 422. Since 2026-11-20 the spec declares the code of each as an enum on error.code:

route status error.code
create, update 409 quota-exceeded, logical-id-taken
create 422 invalid-hostname, service-not-on-a-branch, validation-error
update 422 invalid-hostname, service-on-another-branch, validation-error

The SDK returned all of them as Conflict or UnprocessableEntity, which keep only the message.

An error the API no longer returns. createWorkspaceDomainOwnership listed DomainOwnershipRequired (422 domain-ownership-required). For a valid hostname Prisma now saves the domain ownership and returns it, verified when DNS already has the TXT record and unverified otherwise; the spec lists a 422 on this route for an invalid hostname only.

Evidence for both is Prisma's published spec, GET https://api.prisma.io/v1/doc. No live account was used.

What changed

Only packages/prisma:

  • patch 007: types the five RoutingUrl refusals on /error/code, as patch 005 does for DomainOwnershipRequired. validation-error and any other code stay UnprocessableEntity and Conflict.
  • patch 005: no longer adds DomainOwnershipRequired to createWorkspaceDomainOwnership. It still types it on createServiceDomain, where the spec still documents it.
  • spec mirror fc91281 → e48eb8d (2026-11-21). Apart from the above, the regeneration adds Conflict to createWorkspace and a required state member to every RoutingUrl output (what the hostname is doing now, such as waiting_for_dns or certificate_failed); the rest of the diff in management.ts is the spec's reworded descriptions of a RoutingUrl's status and records, and the generator renumbering its schema indexes.

Breaking (!): createWorkspaceDomainOwnership no longer fails with DomainOwnershipRequired; createServiceUrl and updateUrl can fail with four new typed errors each; createWorkspace can fail with Conflict; RoutingUrl outputs have a required state.

An earlier version of this pull request also exposed the HTTP status of two creates and changed core and the shared generator for it. That is removed, as agreed in the comments.

Checks: pnpm typecheck:ci, pnpm vitest run packages/core packages/prisma, pnpm format:check, pnpm lint (0 errors), pnpm specs:check, pnpm patches:audit prisma (all patches needed).

Agent: prospero-20

🤖 Generated with Claude Code

Note

This comment was left by an agent on behalf of @wmadden
model: fable 5.2
harness: Claude Code in the Claude desktop app (Claude Agent SDK 0.3.330)

As an agent I have read the CONTRIBUTING.md and AGENTS.md and understand the risks of getting @wmadden flagged as untrustworthy if I regularly violate the outlined rules

…ode()

makeRestProtocol now sets an output member marked T.ResponseCode() to the response status. An idempotent create that answers 201 when it creates and 200 when the resource already existed can then say which happened.

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…body

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…mainOwnershipRequired

Since 2026-11-06 the platform saves a domain ownership without its TXT record as unverified and returns it, instead of answering 422 domain-ownership-required. Patch 005 now adds DomainOwnershipRequired to createServiceDomain only.

Regenerated from the 2026-11-19 Management API spec, which also adds Conflict to createWorkspace.

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…mainOwnership

Both creates answer 201 when they create and 200 when the resource already existed, with the same body. Patch 006 adds an httpStatus member bound to the response code, so a caller can tell whether it owns what came back.

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
github-actions Bot added a commit that referenced this pull request Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Benchmarks: PR f3bce8aa6 vs main 51ba3a2c6

  • ⚪ Bundle size 54.8 KB: +0.1% (+77 B), same as main
  • ⚪ Runtime speed 2.7 µs: −52.3% (−3.0 µs), same as main
  • ⚪ Runtime memory 790.6 KB: +3.2% (+24.3 KB), same as main
  • ⚪ Objects at import 1,047: +0.2% (+2), same as main
  • ⚪ Whole-SDK memory aws 39.7 MB (+0.0%), cloudflare 8.27 MB (+0.0%), gcp 24.8 MB (+0.0%)
  • ⚪ Repo size 543.9 MB tracked in 9,895 files, same as main (+5.6 KB). .generated-specs/ 0 B, src/services/ 512.0 MB, everything else 31.9 MB.

sdk-memory

bundle-programs

memory-programs

bundle memory
speed objects

Numbers

🟡 Timings moved, may be runner noise: added latency (p50) on 1 (up to −56.2%, fly-io~SpritesProtocol); import time on 4 (up to −42.2%, neon); first call on 4 (up to −43.2%, neon)

Metric Change vs main Programs
Bundle (gzip) no change 18
Import heap no change 7
Objects at import no change 7
Added latency (p50) ¹ 1 better 7
Import time ¹ 4 better 7
First call ¹ 4 better 7
Program Call Bundle (gzip) Import heap Objects at import Added latency (p50) Import time First call
aws s3.listBuckets 79.4 KB — — — — —
aws~awsJson1_0 dynamodb.listTables 71.7 KB — — — — —
aws~awsJson1_1 kms.listKeys 70.9 KB — — — — —
aws~awsQuery sts.getCallerIdentity 72.3 KB — — — — —
aws~ec2Query ec2.describeRegions 72.4 KB — — — — —
aws~restJson1 lambda.listFunctions 73.1 KB — — — — —
azure resources.ListTenants 57.0 KB — — — — —
cloudflare workers.listScripts 69.3 KB — — — — —
cloudflare~CloudflareProtocol ips.listIps 49.9 KB — — — — —
fly-io machines.getRegions 50.9 KB 776.9 KB 1,090 3.9 µs 9.3 ms (−29.7%) 🟢 3.6 ms (−34.5%) 🟢
fly-io~FlyApiProtocol mpg.listUsers 50.7 KB 669.0 KB 984 2.7 µs 8.3 ms 3.5 ms
fly-io~SpritesProtocol sprites.createOrganizationToken 51.3 KB 707.2 KB 1,026 6.1 µs (−56.2%) 🟢 8.7 ms (−26.1%) 🟢 3.6 ms (−31.6%) 🟢
gcp storage_v1.listBuckets 51.8 KB — — — — —
github gists.list 53.5 KB 626.9 KB 956 3.1 µs 8.4 ms 3.9 ms
neon neon.listProjects 52.2 KB 838.7 KB 1,086 2.1 µs 9.1 ms (−42.2%) 🟢 3.8 ms (−43.2%) 🟢
prisma management.getBuilds 50.1 KB 772.1 KB 1,047 1.4 µs 8.4 ms 3.4 ms
resend resend.listLogs 52.0 KB 860.3 KB 1,146 1.9 µs 9.0 ms (−34.5%) 🟢 3.5 ms (−30.9%) 🟢
stripe stripe.GetFiles 50.1 KB — — — — —

PR f3bce8aa6 against main 51ba3a2c6 (main's cached run from 2026-11-18 20:50 UTC). 18 programs, measured in 78 s on 8 vCPU.

Package Tarball Unpacked Files
core 331.6 KB (+0.1%) 1.3 MB (+0.1%) 229
fly-io 249.9 KB 1.6 MB 71
github 2.1 MB 19.6 MB 338
neon 221.4 KB 1.2 MB 47
prisma 121.3 KB (+0.1%) 876.2 KB (+0.1%) 49
resend 173.2 KB 1.2 MB 57
Tracked files Size Change vs main Files
services 512.0 MB +667 B 3,024
in-tree-specs 98.3 KB ±0 B 4
patches 10.1 MB +1.3 KB 4,188
handwritten 9.6 MB +3.7 KB 1,957
benches 9.6 MB ±0 B 207
other 2.6 MB ±0 B 515
Total 543.9 MB +5.6 KB 9,895

What a checkout or worktree writes to disk, from git ls-tree (benches/repo-size/tree.ts). The dashboard's Repo size page has the full picture.

Effect alone: effect-minimal bundle 8.9 KB gzip, hand-written effect-http call 48.6 KB gzip; effect import 76.6 ms and 12.8 MB heap; bare mocked HTTP roundtrip 11.6 µs p50.

Bundled (from src/): resend, neon, github, fly-io, aws, cloudflare, gcp, azure, stripe, prisma. Built and probed (from lib/): resend, neon, github, fly-io, prisma. Changed in this PR: prisma.

Job time: bundle 8.2 s, build: tsrs 2.3 s, build: bundle-lib 43.6 s, build: strip-lib-docs 0.1 s, build 46.0 s, size 1.1 s, runtime 16.5 s, providers 5.9 s.

¹ Timings run on a different runner than main's, so 🟡 marks a large move that may still be noise. Sizes, heap and object counts are stable. Offline: every call hits a canned in-memory response. Full suite: node benches/sdks/run.ts. Job log

@alchemy-version-bot

Copy link
Copy Markdown
Contributor

Install the packages built from this commit:

@distilled.cloud (122)
pnpm install https://pkg.distilled.cloud/@distilled.cloud/acme/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/adyen/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/anthropic/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/apache-superset/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/archil/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/argocd/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/auth0/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/aws/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/aws4signer/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/axiom/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/azure/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/boat-dev/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/boxd/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/celld/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/chronosphere/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/clerk/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/clickhouse-cloud/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/cloudflare/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/coinbase/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/coinflow/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/convex/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/coolify/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/core/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/customerio/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/datadog/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/daytona/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/digitalocean/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/discord/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/docker/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/dokploy/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/doppler/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/e2b/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/elasticsearch/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/entire/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/exa/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/expo-eas/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/fly-io/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/forgejo/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/gcp/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/github/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/google-workspace/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/grafana/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/growthbook/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/gusto/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/hetzner/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/hostinger/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/huggingface/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/hydradb/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/iceberg/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/infisical/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/inngest/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/intercom/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/kubernetes/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/launchdarkly/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/linear/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/mailchimp/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/meilisearch/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/mercury/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/metabase/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/modal/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/modrinth/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/mongodb-atlas/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/mux/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/namespacelabs/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/neon/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/netbird/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/notion/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/npm/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/okta/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/onepassword/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/opencode/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/opensearch/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/ovh/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/paypal/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/plaid/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/planetscale/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/polar/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/polymarket/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/porkbun/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/posthog/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/prisma/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/proxmox/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/questrade/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/railway/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/redis-cloud/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/remote/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/render/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/resend/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/revenuecat/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/rivet/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/s2/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/s3/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/scaleway/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/sentry/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/slack/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/spacetimedb/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/squarespace/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/stackit/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/starburst-galaxy/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/steel/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/stripe/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/supabase/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/surrealdb/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/tailscale/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/technitium/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/temporal/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/tencentcloud/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/tinybird/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/trigger-dev/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/turbopuffer/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/turso/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/twitch/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/typesense/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/unkey/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/vanta/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/vercel/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/whatsapp/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/whop/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/workos/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/xata/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/zendesk/pr:1348:f3bce8a
pnpm install https://pkg.distilled.cloud/@distilled.cloud/zerossl/pr:1348:f3bce8a

Published Nov 20, 2026, 7:38 AM UTC. Expires Nov 27, 2026, 7:38 AM UTC, extended while this pull request is open.

… and httpStatus is required

The shared generator binds the standard smithy.api#httpResponseCode trait to T.ResponseCode(), next to httpHeader, so Prisma no longer needs its own binding. No converter emits the trait, so no other SDK changes; regenerating AWS from its mirror changes nothing.

Patch 006 marks httpStatus required, so its type is number. Its documentation now says it is the status of the last attempt, since a retried create that already succeeded answers 200. The patch description says the spec is correct and this is an SDK addition.

responseCodeKey and withResponseCode move to protocol-http.ts, next to withResponseHeaders. The test that fed an array body to a structure output is removed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
@wmadden wmadden changed the title feat(core,prisma)!: HTTP status on REST outputs, and Prisma domain ownership statuses feat(core,prisma)!: read a REST response's HTTP status, and type Prisma's RoutingUrl refusals Nov 20, 2026
createServiceUrl and updateUrl fail with one error per refusal, matched on error.code: RoutingUrlQuotaExceeded (409 quota-exceeded), RoutingUrlLogicalIdTaken (409 logical-id-taken), RoutingUrlInvalidHostname (422 invalid-hostname), RoutingUrlServiceNotOnABranch (422 service-not-on-a-branch, create only) and RoutingUrlServiceOnAnotherBranch (422 service-on-another-branch, update only). RoutingUrlQuotaExceeded is also a QuotaError and RoutingUrlLogicalIdTaken an AlreadyExistsError. A 422 validation-error, or any other code, is still Conflict or UnprocessableEntity.

Regenerated from the 2026-11-21 Management API spec (mirror e48eb8d), which declares these codes as enums on each response. It also adds a required `state` to every RoutingUrl output and types the 409 and 422 error bodies. The rest of the generated diff is chunk renumbering.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
@Mkassabov

Copy link
Copy Markdown
Collaborator

yeah.... this doesn't seem like a good idea to me.

There are 2 schools of thought contributing to my opinion on that:

  1. A user should never really need to think about status codes when using a distilled sdk; if it succeded its a success; if its anything else its an error with a tag.
  2. this is not really a success case from prisma; its the prisma api saying something was a success when it really wasn't. if something failed to get created because it already exists, returning the thing that already exists and saying success is just a like? IMO prisma should change their api here to actually treat this as an error - and in that spirit distilled should also treat this as an error

Main removed the protocol layer form and declares errors on the operation, the service and the protocol. Adapted to it:

- core/protocol-rest: kept main's restProtocol structure; decodeSuccess still takes the response status, and openFramed's two calls now pass response.status.
- core test: the response code describe block is named after restProtocol, as main renamed the others.
- prisma: management.ts regenerated with pnpm generate prisma on spec mirror e48eb8d. Patches 005, 006 and 007 needed no change; the generated operations now list serviceErrors as main does.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
@wmadden

wmadden commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

A user should never really need to think about status codes when using a distilled sdk; if it succeded its a success; if its anything else its an error with a tag.

I agree that users of the Alchemy provider API should never need to see HTTP status codes. However, the Distilled SDK exists to generate a client from platform API specs. The Prisma API returns both outcomes as a success, with the status the only thing that tells them apart: 201 means this call created the resource, 200 means it already existed, and the body is the same.

Distilled already models this the same way in other places. T.ResponseCode() is in core on main, the AWS and S3 protocols fill it with response.status, and several AWS services declare it. Core's own doc comment on an operation's default success code says "a ResponseCode() member can still read the actual code". This PR makes the generic REST protocol do what those two protocols already do, and uses it on two Prisma creates. It doesn't add a new concept.

Alchemy's users never see the status. Only the resource's internals read it, to decide whether the stack owns the row or has to ask for --adopt.

this is not really a success case from prisma; its the prisma api saying something was a success when it really wasn't.

That's what an idempotent create is: asking for something that already exists succeeds and returns it. That's deliberate, and we won't change the API to report it as an error. This is a ubiquitous pattern across HTTP and REST APIs.

If we accept your suggestion to return this as "success or tagged error", the SDK would need to convert the 200 into an error itself. That would mean:

  • The client retries a create after a 503 or a dropped connection. If the first attempt created the row and its reply was lost, the retry gets 200, and the caller would see "already exists" for a row its own call made
  • The SDK would report a failure for a call the API says succeeded
  • Errors are only matched on statuses of 400 and above, so core would need a new feature for it

I think it's a better solution to simply retain httpStatus, since it's consistent with Distilled's existing implementation and HTTP APIs in general.

wmadden-electric and others added 2 commits November 23, 2026 17:08
The Prisma SDK is regenerated on main's generator.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
@Mkassabov

Copy link
Copy Markdown
Collaborator

@wmadden

distilled generates clients from the spec, not from the mirror of the actual http layer; Distilled SDK users also shouldn't need to deal with status codes, thats why we convert them into typed errors for users.

the AWS values come from AWS's own specs. you work at Prisma, if consumers of the api need to know if a create made the resource or not that should go in the API, not a patch in our SDK that adds a value the spec doesn't have.

If we accept your suggestion to return this as "success or tagged error", the SDK would need to convert the 200 into an error itself. That would mean:

  • The client retries a create after a 503 or a dropped connection. If the first attempt created the row and its reply was lost, the retry gets 200, and the caller would see "already exists" for a row its own call made
  • The SDK would report a failure for a call the API says succeeded
  • Errors are only matched on statuses of 400 and above, so core would need a new feature for it

this exact argument shows why this is irrelevant here, since a 503 and a retry would put alchemy in the incorrect state where it think it didn't create this and therefore alchemy would treat the resource as found not created, no?

if you want creates to be safe to retry you should use an idempotency key, like other SDKs use. we have good support for this in distilled where we will create one for the user if the field has the appropriate trait

@wmadden

wmadden commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@Mkassabov ok, I will remove the HTTP status handling from the PR.

We will not change the API's behavior for a single consumer. I'd be happy to add metadata to the OpenAPI spec but I can't see a way to express the meaning of the response code in the same way the AWS implementation does, so we'll just drop that information.

wmadden-electric and others added 4 commits November 23, 2026 20:48
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…for it

The REST protocol, its helpers, their tests and the shared generator are back to main. The Prisma SDK no longer exposes the create response status.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
… no longer return httpStatus

Patch 006 is gone, so the two create results carry only what Prisma's spec declares.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…t verified

The spec says the create returns the domain ownership verified when its TXT record already carries the workspace's value, and unverified otherwise.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
@wmadden wmadden changed the title feat(core,prisma)!: read a REST response's HTTP status, and type Prisma's RoutingUrl refusals feat(prisma)!: type the RoutingUrl refusals, on the 2026-11-21 spec Nov 23, 2026
@wmadden
wmadden marked this pull request as draft November 24, 2026 10:53
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.

3 participants