Skip to content

feat(cli): send the project name as logicalId on project create - #289

Closed
kristof-siket wants to merge 1 commit into
mainfrom
feat/project-create-logical-id
Closed

kristof-siket wants to merge 1 commit into
mainfrom
feat/project-create-logical-id

Conversation

@kristof-siket

Copy link
Copy Markdown
Contributor

Why

The Prisma Data Platform records a declared identity, logicalId, on projects. The rule is that only a declaration assigns a logical id. prisma project create <name> is a user explicitly naming a project, so it counts as a declaration. This is the CLI half of the platform change in prisma/pdp-control-plane#5480. The Management API already accepts logicalId on POST /v1/projects in production.

What changed

  • project create sends the name as logicalId when the name fits the format the API validates for a project logical id: ^[a-z0-9][-_a-z0-9]*$ (from ProjectCreateInputSchema in services/management-api/models/v1/projects.ts; there is no length limit). A name outside that format creates the project as before, with no logicalId, no error, and no warning.
  • The app provider now posts to /v1/projects itself. ComputeClient.createProject in @prisma/compute-sdk 0.43.0 (the latest release) does not forward logicalId. The request body is otherwise the same (name, createDatabase: false, region). A failed request still surfaces the API's message, and it now keeps the HTTP status on the error, so the existing 401/403 permission fix keeps working.
  • project link is unchanged. It sends no logicalId when it creates a project from the picker.
  • A second project create with the same logical id in a workspace returns 409 (A project with logicalId "<name>" already exists in this workspace). The existing PROJECT.CREATE_FAILED mapping already shows that reason and points at project list and project link, so no new error handling was added.

Tests

  • New unit tests in packages/cli/tests/project.test.ts:
    • a valid name sends logicalId
    • names that do not fit the format (My App, My-App, _app, app.v2) send none
    • a 409 maps to PROJECT.CREATE_FAILED with the API's reason
  • The project link picker test now checks the exact request body, so it fails if link ever sends a logicalId.
  • pnpm lint, pnpm typecheck, and pnpm --filter @prisma/cli test (64 files, 1027 passed, 2 skipped) all pass.
  • The e2e suite needs PRISMA_E2E_SERVICE_TOKEN, which was not available locally, so it runs in CI only. Its scratch project names are lowercase and unique, so they now also send a logicalId against the real API.

🤖 Generated with Claude Code

`project create <name>` is a user naming a project, which is a
declaration, so the CLI now sends the name as the project's logicalId
when it fits the format the Management API validates
(^[a-z0-9][-_a-z0-9]*$). A name outside that format creates the project
as before, with no logicalId.

The provider now posts to /v1/projects itself, because
ComputeClient.createProject does not forward logicalId. `project link`
still sends no logicalId.

A duplicate logicalId in the workspace returns 409, which the existing
PROJECT.CREATE_FAILED mapping already shows with the API's reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 25, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

npx https://pkg.pr.new/@prisma/cli@289
npx https://pkg.pr.new/@prisma/cli-engine@289

commit: 7529016

@kristof-siket

Copy link
Copy Markdown
Contributor Author

Closing without merging. A project's logical id is assigned only by a declaration, such as a Composer module or the Console connect flow. project create writes no declaration, so it should leave the logical id null. Composer still finds a project created this way by its display name. The Composer import plan in prisma/pdp-control-plane is being updated to match.

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