Skip to content

Conversation

@aidankmcalister
Copy link
Member

@aidankmcalister aidankmcalister commented Dec 14, 2025

Summary by CodeRabbit

  • New Features

    • Added optional --userAgent CLI flag (alias -u) to specify custom user agent strings during database creation.
  • Updates

    • User agent now accepts custom values when provided, or automatically derives from environment variables.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 14, 2025

Walkthrough

Added an optional CLI input option userAgent to the create command that accepts a custom user agent string. The implementation uses the provided value if given, otherwise constructs it from environment variables. Analytics tracking was updated to reflect whether a user agent was supplied.

Changes

Cohort / File(s) Summary
CLI input and user agent handling
create-db/src/index.ts
Added optional userAgent CLI option (string, alias u) with fallback to environment-based construction from PRISMA_ACTOR_NAME and PRISMA_ACTOR_PROJECT. Updated analytics flag from has-env-flag to has-user-agent to track user agent provision.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single file modification with additive CLI parameter and fallback logic
  • Straightforward conditional logic for user agent sourcing
  • Analytics flag update is straightforward

Possibly related PRs

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a new user agent flag (CLI option) to the create command. It's specific, concise, and clearly reflects the primary modification in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 14, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
claim-db-worker e02ae35 Commit Preview URL

Branch Preview URL
Dec 14 2025, 10:03 PM

@github-actions
Copy link

Preview CLIs & Workers are live!

Test the CLIs locally under tag pr70-add-undocumented-user-agent-flag-20214743863:

npx create-db@pr70
npx create-pg@pr70
npx create-postgres@pr70

Worker URLs
• Create-DB Worker: https://create-db-temp.prisma.io
• Claim-DB Worker: https://create-db.prisma.io

These will live as long as this PR exists under tag pr70-add-undocumented-user-agent-flag-20214743863.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
create-db/src/index.ts (1)

120-124: Consider documenting the fallback behavior and adding format validation.

The implementation is correct, but two optional improvements:

  1. The description doesn't mention that if userAgent is not provided, it falls back to PRISMA_ACTOR_NAME/PRISMA_ACTOR_PROJECT from the .env file.
  2. The example format 'test/test' suggests a pattern, but there's no validation to enforce it.

To add format validation, you could use a regex refinement:

 userAgent: z
   .string()
   .optional()
+  .refine((val) => !val || /^[\w-]+\/[\w-]+$/.test(val), {
+    error: () => "User agent must be in format 'name/project' (e.g. 'test/test')"
+  })
   .describe("Custom user agent string (e.g. 'test/test')")
   .meta({ alias: "u" }),

To document the fallback behavior:

-  .describe("Custom user agent string (e.g. 'test/test')")
+  .describe("Custom user agent string (e.g. 'test/test'). Falls back to PRISMA_ACTOR_NAME/PRISMA_ACTOR_PROJECT from .env if not provided")
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83b8fe6 and e02ae35.

📒 Files selected for processing (1)
  • create-db/src/index.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
create-db/src/index.ts (2)
create-db/src/database.ts (1)
  • getCommandName (5-10)
create-db/src/env-utils.ts (1)
  • readUserEnvFile (4-23)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Workers Builds: create-db-worker
  • GitHub Check: Workers Builds: claim-db-worker
🔇 Additional comments (4)
create-db/src/index.ts (4)

131-137: LGTM! Clean fallback logic.

The implementation correctly prioritizes the CLI-provided userAgent and only reads the environment file when needed. The constructed format name/project matches the documented example.


203-207: LGTM! Consistent userAgent propagation.

Both invocations of createDatabaseCoreWithUrl correctly pass the userAgent parameter, ensuring consistent behavior across json/env and interactive modes.

Also applies to: 295-299


393-396: LGTM! Programmatic API correctly supports userAgent.

The create() function properly forwards the optional userAgent from options to createDatabaseCoreWithUrl, and the JSDoc documentation has been updated accordingly.


147-147: > Likely an incorrect or invalid review comment.

@aidankmcalister aidankmcalister merged commit f4d126d into main Dec 14, 2025
6 checks passed
@aidankmcalister aidankmcalister deleted the add-undocumented-user-agent-flag branch December 14, 2025 22:16
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.

2 participants