Skip to content

feat(cli-engine): send deploy source and client headers to the Management API - #257

Open
gregory-boch-prisma wants to merge 2 commits into
mainfrom
feat/management-api-deploy-headers
Open

feat(cli-engine): send deploy source and client headers to the Management API#257
gregory-boch-prisma wants to merge 2 commits into
mainfrom
feat/management-api-deploy-headers

Conversation

@gregory-boch-prisma

@gregory-boch-prisma gregory-boch-prisma commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Problem

The Management API records Compute deploys in its analytics, but it cannot tell which tool sent a request or whether it ran in GitHub Actions. The CLI's requests carry only the runtime's default User-Agent (node or Bun/x.y.z), which any Node or Bun script also sends.

Change

Every request from the engine's Management API client (ctx.api) now carries three headers:

Header Value
x-prisma-client-name prisma-cli
x-prisma-client-version the CLI version, from getCliVersion()
x-prisma-deploy-source github-action when GITHUB_ACTIONS is "true", otherwise cli
  • The headers are added by an openapi-fetch onRequest middleware on sdk.client, the same way the SDK adds Authorization.
  • The version reaches the engine through a new optional cliVersion field on ManagementApiClientConfig. A host that does not set it simply omits x-prisma-client-version.
  • ctx.api carries Composer's build reports during prisma deploy and the prisma service commands, so both are covered.
  • @prisma/cli-engine is bumped from 0.3.0 to 0.3.1 with pnpm bump-cli-engine-version patch, because published engine versions cannot change.

The headers change analytics only. The API behaves the same with or without them, and they carry no user data: just the tool name, its version, and whether the run is in GitHub Actions.

The server side is prisma/pdp-control-plane#5284. A matching change for Composer's alchemy client covers the deployment create and start calls, which do not go through ctx.api.

Verification

  • pnpm typecheck and pnpm lint are clean.
  • pnpm --filter @prisma/cli-engine test: 830 passed. New tests check the headers inside and outside GitHub Actions, and that x-prisma-client-version is left out when cliVersion is not set. They go through the real client with a stubbed fetch.
  • pnpm --filter @prisma/cli test: 964 passed, 2 skipped. bin.test.ts now expects cliVersion in the assembled config.
  • pnpm --filter @prisma/compute test: 11 passed.
  • No command was added or changed, so the e2e suite is not affected.

🤖 Generated with Claude Code

…ment API

The Management API records where each Compute deploy came from in its
analytics. Every request from the engine's Management API client now
carries:

- x-prisma-client-name: prisma-cli
- x-prisma-client-version: the CLI version
- x-prisma-deploy-source: github-action when GITHUB_ACTIONS is "true",
  otherwise cli

The API behaves the same with or without them. The version reaches the
engine through a new optional cliVersion field on
ManagementApiClientConfig, so hosts that do not set it keep working.

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

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Essentials

Run ID: cde200db-dde9-41c9-9549-c3da2bd89e66

📥 Commits

Reviewing files that changed from the base of the PR and between 3a97d2c and b6287c6.

📒 Files selected for processing (5)
  • packages/cli-engine/src/execution/api-client.ts
  • packages/cli-engine/src/management-api.ts
  • packages/cli-engine/tests/management-api.test.ts
  • packages/cli/src/runtime.ts
  • packages/cli/tests/bin.test.ts

Included review availability: 2 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


Summary by CodeRabbit

  • Enhancements
    • Management API requests now include CLI name, version, and deployment-source information.
    • Deployments from GitHub Actions are identified separately from standard CLI deployments.
    • The current CLI version is automatically provided when available.
  • Tests
    • Added coverage validating request metadata and deployment-source detection.

Walkthrough

The management API client now adds CLI name, optional CLI version, and deploy-source headers to requests. The deploy source is github-action in GitHub Actions and cli otherwise. Runtime assembly passes the current CLI version into the client configuration. Tests cover header values, omitted versions, and runtime configuration.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to b6287

CLI requests receive the intended identification headers while preserving behavior when no CLI version is available. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: adding deploy-source and client-identification headers to Management API requests.
Description check ✅ Passed The description is directly related to the changeset. It explains the new headers, configuration flow, compatibility behavior, tests, and verification results.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/management-api-deploy-headers
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/management-api-deploy-headers

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 76e7c0b

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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