Skip to content

Conversation

aidankmcalister
Copy link
Member

@aidankmcalister aidankmcalister commented Aug 27, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of environment-configured service URLs: preserves provided trailing slashes and avoids errors when variables are unset, while continuing to use default endpoints when unspecified.
  • Chores

    • Bumped package versions to 1.0.6 for related packages.

Copy link

cloudflare-workers-and-pages bot commented Aug 27, 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 8a9936e Commit Preview URL

Branch Preview URL
Aug 27 2025, 05:53 PM

Copy link

coderabbitai bot commented Aug 27, 2025

Walkthrough

Updated create-db/index.js to use direct environment variable checks with defaults for CREATE_DB_WORKER_URL and CLAIM_DB_WORKER_URL, removing trailing-slash trimming. Bumped package versions to 1.0.6 in create-db, create-pg, and create-postgres.

Changes

Cohort / File(s) Summary
Env URL initialization (create-db)
create-db/index.js
Switched to `process.env.CREATE_DB_WORKER_URL
Version bumps
create-db/package.json, create-pg/package.json, create-postgres/package.json
Incremented "version" from 1.0.5 to 1.0.6.

Possibly related PRs

  • feat: --source flag added #45: Adjusts claim URL usage to include utm_source/userAgent and threads userAgent through createDatabase; touches the same URL handling logic.
  • DC-4894 Move PostHog to worker #48: Introduces trailing-slash trimming when moving analytics to the worker; directly related to the trimming logic now removed.

Suggested reviewers

  • nurul3101
  • ankur-arch
  • mhessdev
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch remove-replace

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Preview CLIs & Workers are live!

Test the CLIs locally under tag pr50-remove-replace-17274596200:

npx create-db@pr50
npx create-pg@pr50
npx create-postgres@$pr50

Worker URLs
• Create-DB Worker:
• Claim-DB Worker:

These will live as long as this PR exists under tag pr50-remove-replace-17274596200.

@aidankmcalister aidankmcalister merged commit 08d3135 into main Aug 27, 2025
3 of 4 checks passed
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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between fdff981 and 8a9936e.

📒 Files selected for processing (4)
  • create-db/index.js (1 hunks)
  • create-db/package.json (1 hunks)
  • create-pg/package.json (1 hunks)
  • create-postgres/package.json (1 hunks)
⏰ 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: claim-db-worker
  • GitHub Check: Workers Builds: create-db-worker
🔇 Additional comments (3)
create-postgres/package.json (1)

3-3: Version bump looks good.

Consistent with the other packages in this PR. No issues.

create-db/package.json (1)

3-3: Version bump looks good.

Aligned with dependent workspace packages. No concerns.

create-pg/package.json (1)

3-3: Version bump looks good.

Matches the workspace set. Ship it.

Comment on lines 15 to +18
const CREATE_DB_WORKER_URL =
process.env.CREATE_DB_WORKER_URL.replace(/\/+$/, "") ||
"https://create-db-temp.prisma.io";
process.env.CREATE_DB_WORKER_URL || "https://create-db-temp.prisma.io";
const CLAIM_DB_WORKER_URL =
process.env.CLAIM_DB_WORKER_URL.replace(/\/+$/, "") ||
"https://create-db.prisma.io";
process.env.CLAIM_DB_WORKER_URL || "https://create-db.prisma.io";
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Avoid double-slash endpoints after removing trailing-slash trim

Direct concat will produce URLs like ...//analytics if the env var ends with /. Many servers tolerate it, but some proxies/CDNs can 301/404 or log differently. Prefer URL-based joining to keep the “no replace” intent and be robust.

Apply this minimal change near the constants:

-const CREATE_DB_WORKER_URL =
-  process.env.CREATE_DB_WORKER_URL || "https://create-db-temp.prisma.io";
-const CLAIM_DB_WORKER_URL =
-  process.env.CLAIM_DB_WORKER_URL || "https://create-db.prisma.io";
+const CREATE_DB_WORKER_URL =
+  process.env.CREATE_DB_WORKER_URL || "https://create-db-temp.prisma.io";
+const CLAIM_DB_WORKER_URL =
+  process.env.CLAIM_DB_WORKER_URL || "https://create-db.prisma.io";
+const joinUrl = (base, pathOrQuery) => new URL(pathOrQuery, base).toString();

Then update call sites (examples):

  • fetch(joinUrl(CREATE_DB_WORKER_URL, "/analytics"), ...)
  • const healthUrl = joinUrl(CREATE_DB_WORKER_URL, "/health")
  • const url = joinUrl(CREATE_DB_WORKER_URL, "/regions")
  • fetch(joinUrl(CREATE_DB_WORKER_URL, "/create"), ...)
  • const claimUrl = joinUrl(CLAIM_DB_WORKER_URL, \?projectID=${projectId}&utm_source=${userAgent}&utm_medium=cli`)`

Quick check to run locally: set CREATE_DB_WORKER_URL with and without a trailing slash and verify no // appears in requests and no redirects occur.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const CREATE_DB_WORKER_URL =
process.env.CREATE_DB_WORKER_URL.replace(/\/+$/, "") ||
"https://create-db-temp.prisma.io";
process.env.CREATE_DB_WORKER_URL || "https://create-db-temp.prisma.io";
const CLAIM_DB_WORKER_URL =
process.env.CLAIM_DB_WORKER_URL.replace(/\/+$/, "") ||
"https://create-db.prisma.io";
process.env.CLAIM_DB_WORKER_URL || "https://create-db.prisma.io";
// src/create-db/index.js
const CREATE_DB_WORKER_URL =
process.env.CREATE_DB_WORKER_URL || "https://create-db-temp.prisma.io";
const CLAIM_DB_WORKER_URL =
process.env.CLAIM_DB_WORKER_URL || "https://create-db.prisma.io";
// Helper to robustly join a base URL and a path or query string without producing “//”
const joinUrl = (base, pathOrQuery) => new URL(pathOrQuery, base).toString();
🤖 Prompt for AI Agents
In create-db/index.js around lines 15-18 the constants are concatenated with
paths which can produce double-slash URLs if the env vars end with a trailing
slash; implement a small URL-joining helper (e.g., joinUrl(base, path) that
normalizes trailing/leading slashes or uses the URL API) and replace direct
concatenations at the listed call sites so calls become
fetch(joinUrl(CREATE_DB_WORKER_URL, "/analytics"), ...), const healthUrl =
joinUrl(CREATE_DB_WORKER_URL, "/health"), const url =
joinUrl(CREATE_DB_WORKER_URL, "/regions"), fetch(joinUrl(CREATE_DB_WORKER_URL,
"/create"), ...), and const claimUrl = joinUrl(CLAIM_DB_WORKER_URL,
`?projectID=${projectId}&utm_source=${userAgent}&utm_medium=cli`); verify
locally by setting the env vars with and without trailing slashes to ensure no
"//" appears and no redirects occur.

@coderabbitai coderabbitai bot mentioned this pull request Sep 3, 2025
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