You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f5566e0
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix(prisma-cloud): Composer identifies itself on every Management API call, and deploys stop writing a DATABASE_URL placeholder (#449)
* fix(prisma-cloud): deploys no longer write a "-" placeholder under DATABASE_URL and DATABASE_URL_POOLED
A deploy wrote the value "-" under DATABASE_URL and DATABASE_URL_POOLED in the project's production and preview classes, on the belief that the platform fills in a missing DATABASE_URL from any ready database on the first Compute deploy. The platform does not: it writes DATABASE_URL only when a project is created with a database or a database is created as its default, and Composer creates projects without one. The rows protected nothing.
The deploy now makes no call for either name. Apps still cannot declare either name as a platform variable, and old deploy state that tracked the two variables is still retired on read. Rows written by earlier versions stay on existing projects.
The design docs, the upstream-provider decision record and the deploying guide now describe what the platform 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>
* fix(prisma-cloud): Composer identifies itself on Management API calls made with the prisma CLI's client
Under prisma deploy the prisma CLI hands Composer its own Management API client. Preflight, the build reporter, the container lookup, the deploy state store, the resource providers and deploy list used that client as it was, so their requests carried the CLI's identity headers, or none. The platform could not tell which Composer version made them.
withDeploySourceHeaders() is a view of the caller's client that sets x-prisma-client-name, x-prisma-client-version and x-prisma-deploy-source on each request, over the client's defaults. The caller's client is not changed, so the CLI's own requests keep its identity. The build reporter's token-built client now sends the headers too.
Taken from the client-headers half of #441. Added here: tests for the state store and providers client, the deploy list read and the container lookup, and the doc comment of layer() moved back onto layer().
Co-authored-by: Tyler Hogarth <5163494+tylerhogarth@users.noreply.github.com>
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>
* docs(decisions): ADR-0048 states what the platform does with DATABASE_URL, without an amendment banner
The record is rewritten in place, as the decision index requires for a changed decision: no amendment banner, and the index entry states what the record decides. The alternative for the placeholder now names both earlier forms, tracked resources in deploy state and then create-only calls, and the Namespaces bullet points at it. The edited item in pdp-data-model.md is one line.
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>
* refactor(prisma-cloud): one function turns the caller's credentials into the client Composer sends requests through
composerClientOf(credentials) returns the caller's client with Composer's identity headers, or undefined. The build reporter, preflight, the container lookup, the state store and the resource providers all use it, so no code outside it reads credentials.client to send a request. The state store and the providers now take the credentials in place of a bare client. readDeployedEnvironment takes a bare client from deploy list and wraps it with withComposerIdentity.
withDeploySourceHeaders is renamed withComposerIdentity, and its helpers say what they return. A new test calls every request method of a real SDK client through the view, so a method a later SDK adds fails it until the view covers it. The test that checked hand-written version strings against a hand-written pattern is deleted.
Co-authored-by: Tyler Hogarth <5163494+tylerhogarth@users.noreply.github.com>
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>
* refactor(prisma-cloud): providers() takes the caller's credentials like its siblings, and only composerClientOf is exported
providers() now takes credentials of the same type as suppliedOrFromEnv and prismaStateLayer. withComposerIdentity is no longer exported from the package, so code that holds credentials gets Composer's client only through composerClientOf. The test that every SDK request method goes through the view now first checks that it found GET and all nine request methods, so it cannot pass on an empty list.
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>
* chore(drive): design, plan and reviews for making Composer work with variable groups
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>
---------
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>
Co-authored-by: Tyler Hogarth <5163494+tylerhogarth@users.noreply.github.com>
-**Preflight does not see a value a user set on one service.** A platform variable set only as a service variable, through Console's "Save and Deploy", is reported unset, and a required one fails the deploy. The fix is one `resolved-variables?serviceId=` read per reading service that already exists, with each key's `updatedAt` added to that service's triggers. Not built because Composer has no way to declare such a value. From the design, section 4.1.
4
+
-**Hints use `prisma project env` for the built-in groups.** Move them to `prisma variable` when it is the CLI most users have.
5
+
-**An app upgrading directly from a version before the address change** can have one service receive another's old row once. The guide tells it to deploy with a release from 0.35.0 to 0.39.0 first. A check in preflight against the deploy state would refuse it instead.
6
+
-**Ask the platform to put the limit and the count in its quota error for service variables.** Composer checks its own count, but cannot count variables a user set in Console.
Three slices, one pull request each. Slice 1 has no outside dependency. Slices 2 and 3 are built now and merged when the platform is ready.
6
+
7
+
## Slice 1: deploys stop writing the `DATABASE_URL` placeholder, and Composer names itself on every API call
8
+
9
+
Design sections 4.3 and 4.4. Builds on: nothing. Hands to slice 2: the client view that adds Composer's headers, used by preflight. Merges as soon as it is reviewed.
10
+
11
+
## Slice 2: preflight asks the platform what the environment receives
12
+
13
+
Design section 4.1. Builds on: slice 1. Merges when the new read is live in production with the missing-group-id defect fixed. Until then the pull request is a draft.
14
+
15
+
## Slice 3: a service's `COMPOSER_` keys travel with its deployment
16
+
17
+
Design section 4.2. Builds on: the open pull request "an unchanged deploy no longer replaces a service that depends on another service", merged. Independent of slice 2. Opened early as a draft, with `pnpm` patches standing in for the upstream packages, for Ty to align his interface against. Needs one pull request on Distilled and one on Alchemy once the platform's field is final. Merges when the platform accepts `variables` in production and both upstream packages have released.
18
+
19
+
## Release
20
+
21
+
0.40.0 after slices 1 and 2, with slice 3 if it is ready.
22
+
23
+
## Close-out
24
+
25
+
-[ ] Check every "Done when" condition in the spec.
26
+
-[ ] Delete `.drive/projects/variable-groups-compat/`; each slice has already landed its docs.
27
+
28
+
## What each pull request description must tell Ty
29
+
30
+
Will, 2026-11-20: the response to Ty is sent and is not edited again. What changed since goes in the pull request descriptions, where Ty reads it.
31
+
32
+
-**Slice 2 (preflight):** the defect on his branch that blocks it. A variable written without a `groupId`, which is what `prisma project env add --role preview` does, is stored with no group. A deployment receives it, but resolved-variables does not list it (`resolved-variables.ts` filters on `groupId` only; `setConfigVariable.ts` stores `input.groupId ?? null`). Preflight would report it missing.
33
+
-**Slice 3 (service variables):** the interface we built against, for him to align; that "keys not sent keep their value" is what we want, and we do not want a way to replace a service's full set, because it would delete values a user set in Console; that we rely on `null` for a key that is not stored being accepted and doing nothing; and the two minimum versions: 0.40.0 for custom groups, and the release with this change for the day branch override writes stop, unless this change is ready in time for 0.40.0.
# Composer works with the platform's variable groups
2
+
3
+
## Purpose
4
+
5
+
Prisma Cloud is replacing its two variable classes with variable groups and service variables, and is removing branch overrides. Every released Composer version gives wrong answers or fails under that model. This project makes new Composer releases deploy correctly under it, so a user's only step is to upgrade.
6
+
7
+
The whole design is in [design.md](design.md). The reviews it was revised against are in `reviews/`.
8
+
9
+
## Non-goals
10
+
11
+
- Patch releases on older Composer lines, and any special treatment of old Composer by the platform (Will, 2026-11-20).
12
+
- A way to set a user's value on one service through `prisma deploy`.
13
+
- Preflight seeing a value a user set on one service. Recorded in [deferred.md](deferred.md).
14
+
- Any change to how an app declares or reads a platform variable, or to core.
15
+
16
+
## Cross-cutting requirements
17
+
18
+
- Every change stays in the Prisma Cloud target, its lowering, its local target and the upstream provider.
19
+
- No platform deploy writes a variable row once the service variables change has landed.
20
+
- A deploy that changes nothing replaces no deployment.
21
+
- Nothing merges to `main` that calls a platform endpoint or sends a request field that production does not have yet, because every merge publishes a `dev` build.
22
+
23
+
## Done when
24
+
25
+
- A deploy to an environment whose branch receives a custom group reports missing and present platform variables correctly, and a value changed in that group replaces the services that read it. Checked against a real platform.
26
+
- A preview deploy makes no write that names a branch.
27
+
- An existing app upgraded from 0.39.0 keeps every service answering, and its old variable rows are gone.
28
+
- 0.40.0 is released, and the response to Ty states the minimum version or versions.
29
+
30
+
## Open question
31
+
32
+
- Whether 0.40.0 waits for the service variables change, or there are two minimum versions (design, section 10).
Copy file name to clipboardExpand all lines: docs/design/05-prisma-cloud/alchemy-lowering.md
+5-17Lines changed: 5 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,23 +49,11 @@ never the container itself (see
49
49
50
50
## `DATABASE_URL` is forbidden — and left to the platform
51
51
52
-
The platform writes `DATABASE_URL` / `DATABASE_URL_POOLED` templates pointing at
53
-
a project's default database — a convenience for hand-provisioned single
54
-
services, and precisely the kind of **implicit ambient config the framework
55
-
exists to eliminate**. The framework never reads it and never depends on it.
56
-
Framework-provisioned Projects are created with `createDatabase: false`, so no
57
-
default database exists on them — but that alone does not keep the variable
58
-
away: the platform self-heals a missing `DATABASE_URL` template on the first
59
-
Compute deploy, wiring it from any ready database on the Project (default
60
-
first, then oldest) — on a Composer Project, one of the app's own databases.
61
-
62
-
So the framework claims the keys first. `application.provision` writes `DATABASE_URL` and `DATABASE_URL_POOLED` (production and preview class, project-level) with the placeholder value `"-"` via create-only calls (`lowering/src/database-url-claim.ts`). The platform's writes are also create-only, so whoever writes first wins permanently: on a fresh Project the claim lands first and the self-heal never fires; on a Project whose variables the platform already seeded, the claim gets a 409 and no-ops. The rows are plain variables on the platform, never Alchemy resources — nothing enters deploy state and upstream's `EnvironmentVariable` never owns them. Alongside the claim, the authoring-side ban holds: `variable()` and `variable.secret()` reject both names (`variable-name.ts`), so no platform variable the app declares can carry one. Every database URL a service actually consumes is an explicit, per-service variable the pack's `serialize` writes under its own named key, inside the `COMPOSER_` namespace.
63
-
64
-
A service that reads `process.env.DATABASE_URL` behind the framework's back
65
-
therefore reads the placeholder `"-"` and fails loudly — or, on a Project the
66
-
platform seeded before the framework ever deployed to it, the platform's own
67
-
template ([deploying.md](../../guides/deploying.md) covers the leftover rows
68
-
and manual cleanup).
52
+
The platform writes `DATABASE_URL` and `DATABASE_URL_POOLED` pointing at a project's default database, and marks them system-managed. It does so only when a project is created with a database, or when a database is created as the project's default. That is a convenience for hand-provisioned single services, and exactly the kind of implicit ambient config the framework exists to eliminate. The framework never reads either variable and never depends on it.
53
+
54
+
Framework-provisioned Projects are created with `createDatabase: false`, and the framework never creates a project default database, so on a Composer Project the platform writes neither variable. The framework writes no row of its own under either name, and nothing about them enters deploy state. The authoring-side ban remains: `variable()` and `variable.secret()` reject both names (`variable-name.ts`), so no platform variable the app declares can carry one. Every database URL a service actually consumes is an explicit, per-service variable the pack's `serialize` writes under its own named key, inside the `COMPOSER_` namespace.
55
+
56
+
A service that reads `process.env.DATABASE_URL` behind the framework's back sees whatever is on the platform under that name: nothing on a Composer Project, the platform's own value on a Project created outside Composer with a default database, or a value the user set. Older framework versions wrote the placeholder `"-"` under both names; those rows stay on existing Projects until the user deletes them ([deploying.md](../../guides/deploying.md) covers them).
every database URL a service consumes is an explicit, service-named variable.
104
+
3.**`DATABASE_URL` is not a separate mechanism.** It is a platform-written template flowing through the same materialization as user variables — a convenience for hand-provisioned single services. The platform owns it (system-managed) and writes it only for a project's default database. Prisma Composer refuses to bind or manage the name and creates no default database (see [alchemy-lowering.md](alchemy-lowering.md#database_url-is-forbidden--and-left-to-the-platform)); every database URL a service consumes is an explicit, service-named variable.
113
105
4.**Branch + class is the platform's environments model** (production
114
106
templates vs preview templates + per-branch overrides) — the substrate
115
107
[an environment as a Branch](../10-domains/deploy-cli.md#environments-and-containers) is
Copy file name to clipboardExpand all lines: docs/design/90-decisions/ADR-0048-prisma-cloud-resources-come-from-the-upstream-alchemy-provider.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,9 +69,9 @@ No plaintext reaches state: members are `Redacted` in props, and only the salted
69
69
70
70
## Consequences
71
71
72
-
-**Namespaces.** The `Prisma.*` resource type-id namespace and the `'Prisma'` collection tag belong to upstream. Composer's collection tag is `'PrismaComposer'` and its own resources are `PrismaComposer.*`. Rows persisted under retired Composer type-ids are rewritten on read by the hosted state store (`state/legacy-resources.ts`): ids, attribute shapes, and the retirement of the legacy claim rows below. The module is the durable compatibility boundary for state written by earlier Composer versions. Scope: "legacy" here means rows already INSIDE the platform state API (ADR-0045), written under retired type-ids or shapes. The older generation — the retired SQL `prisma-composer-state` stores — stays under ADR-0045's own rule: never read, cleaned up by destroy or Branch deletion. The two rules govern different stores and do not overlap.
72
+
-**Namespaces.** The `Prisma.*` resource type-id namespace and the `'Prisma'` collection tag belong to upstream. Composer's collection tag is `'PrismaComposer'` and its own resources are `PrismaComposer.*`. Rows persisted under retired Composer type-ids are rewritten on read by the hosted state store (`state/legacy-resources.ts`): ids, attribute shapes, and the retirement of the `DATABASE_URL` claim rows that earlier versions tracked as resources (see "Claim both names with a placeholder" under Alternatives considered). The module is the durable compatibility boundary for state written by earlier Composer versions. Scope: "legacy" here means rows already INSIDE the platform state API (ADR-0045), written under retired type-ids or shapes. The older generation — the retired SQL `prisma-composer-state` stores — stays under ADR-0045's own rule: never read, cleaned up by destroy or Branch deletion. The two rules govern different stores and do not overlap.
73
73
-**Branch-stage databases carry generated physical names.** Upstream refuses an explicit name combined with branch attachment at create — and it is right to: the Management API creates the database and attaches the branch in separate transactions with no idempotency key, so a lost response is indistinguishable from a foreign database. Attaching after create does not survive either: upstream's reconcile detaches a branch its props don't declare. So branch stages attach at create and take the generated name; production keeps explicit names.
74
-
-**The platform's `DATABASE_URL` is left alone.** Prisma Cloud seeds`DATABASE_URL`/`DATABASE_URL_POOLED`on every app and marks them system-managed; upstream refuses to manage system-managed variables. Composer never overwrites, updates, deletes, or tracks them. It does CREATE them, once, on a fresh Project: `application.provision` claims both names with the placeholder `"-"` via create-only calls (`database-url-claim.ts`), because the platform otherwise self-heals a missing `DATABASE_URL`on the first compute deploy with a live credential to one of the app's own databases. An existing row — platform-seeded or the operator's — makes the claim a 409 no-op. The guarantee that apps read configuration through the framework is held at the authoring end too: `param.ts`/`secret.ts` reject the reserved names, and every Composer-written row is `COMPOSER_`-prefixed. An app that reads `process.env.DATABASE_URL` directly sees whatever the platform put there.
74
+
-**The platform's `DATABASE_URL` is left alone.** Prisma Cloud writes`DATABASE_URL`/`DATABASE_URL_POOLED`only when a project is created with a database, or when a database is created as the project's default, and marks them system-managed; upstream refuses to manage system-managed variables. Composer creates projects without a database and never creates a default one, so the platform writes neither on a Composer project. Composer never creates, overwrites, updates, deletes, or tracks either variable. The guarantee that apps read configuration through the framework is held at the authoring end: `variable()` and `variable.secret()` reject the reserved names (`variable-name.ts`), and every row Composer writes is `COMPOSER_`-prefixed. An app that reads `process.env.DATABASE_URL` directly sees whatever the platform or the user put there.
75
75
-**Auth never touches Alchemy's profile store.** Alchemy's own credential flow prompts on a TTY and hard-fails non-interactive; Composer runs alchemy as a subprocess with piped stdio. Composer provides `PrismaEnvironment` directly from `PRISMA_SERVICE_TOKEN`, with one base-URL resolver shared between upstream's providers and Composer's own SDK client so both always target the same host.
76
76
-**A known weakness is inherited:** upstream retries a conflicting App delete for only a few seconds, where Composer's own resource waited out deployment drain for minutes. Slow drains can fail a destroy and need a re-run.
77
77
@@ -82,6 +82,7 @@ No plaintext reaches state: members are `Redacted` in props, and only the salted
82
82
-**Vendor the provider's source into Composer.** Mechanically possible; inherits its dependencies and permanent drift. Kept only as a fallback if a future alchemy upgrade proves unshippable.
83
83
-**Adopt upstream's built-in dev mode instead of the local target.** Would replace a whole-layer seam that already works with per-provider substitution, and tie local-dev iteration to an external release cadence.
84
84
-**Replace the deployment on every deploy** (the pre-adoption behavior). Ships every change by brute force but gives up upstream's reuse entirely; superseded first by the Composer-side fingerprint, then by `Deployment.triggers`.
85
+
-**Claim both names with a placeholder.** Earlier versions wrote `"-"` under `DATABASE_URL` and `DATABASE_URL_POOLED`, in the production and preview classes at project level, so the platform could not put a live credential there. The first versions did it through tracked `EnvironmentVariable` resources, so the rows were in deploy state; later versions did it with create-only calls outside deploy state. Both rested on the belief that the platform fills in a missing `DATABASE_URL` on the first Compute deploy from any ready database in the project. The platform does not do that, so on a Composer project the rows protected nothing. Rows already written stay on existing projects. State entries from the tracked form are dropped on read by `state/legacy-resources.ts`, with no call to the platform.
85
86
-**Hash environment values Composer-side.** A bare hash of a secret in a plaintext path or state row is an offline-guessing target; rejected. The interim Composer-side fingerprint therefore hashed only material that was non-secret by construction (accepting the re-issued-value narrowing above); upstream's `triggers` avoids the exposure differently — a salted fingerprint computed and persisted inside alchemy's own state, never a bare hash of a secret in the open.
0 commit comments