Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/react-router-example/prisma.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export default defineConfig({
path: "prisma/migrations",
},
datasource: {
url: env("DATABASE_URL"),
// Provide a default value for CI/CD environments where the database URL is not set
// This allows prisma generate to run without connecting to the database
url: env("DATABASE_URL") ?? "postgresql://postgres:postgres@localhost:5432/effectify",
},
Comment on lines 11 to 15

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -name "prisma.config.ts" -type f

Repository: devx-op/effectify

Length of output: 140


🏁 Script executed:

cat -n ./apps/react-router-example/prisma.config.ts

Repository: devx-op/effectify

Length of output: 765


🏁 Script executed:

git log --oneline -n 10 -- ./apps/react-router-example/prisma.config.ts

Repository: devx-op/effectify

Length of output: 146


🏁 Script executed:

find ./apps/react-router-example -type f \( -name "*.yml" -o -name "*.yaml" -o -name ".env*" \) | head -20

Repository: devx-op/effectify

Length of output: 107


🏁 Script executed:

rg "CI|DATABASE_URL" ./apps/react-router-example --type ts --type js -A 2 -B 2

Repository: devx-op/effectify

Length of output: 1231


🏁 Script executed:

cat -n ./apps/react-router-example/docker-compose.yml

Repository: devx-op/effectify

Length of output: 417


🏁 Script executed:

cat -n ./apps/react-router-example/app/lib/prisma.ts

Repository: devx-op/effectify

Length of output: 681


Restrict fallback URL to CI only; avoid masking misconfiguration in dev.

The unconditional fallback to localhost:5432 risks silent misconfiguration during development. If DATABASE_URL is missing when running prisma CLI commands, it will silently connect to the hardcoded local database instead of failing fast. Additionally, the fallback port (5432) differs from the docker-compose setup (5433), compounding the risk.

While runtime protection exists in app/lib/prisma.ts (which enforces DATABASE_URL), the config-level fallback still creates friction during local development. Restrict the fallback to CI environments only:

+const databaseUrl =
+  env("DATABASE_URL") ??
+  (process.env.CI ? "postgresql://postgres:postgres@localhost:5432/effectify" : undefined)
+
+if (!databaseUrl && !process.env.CI) {
+  throw new Error("DATABASE_URL is required outside CI")
+}
+
 export default defineConfig({
   schema: "prisma/schema.prisma",
   migrations: {
     path: "prisma/migrations",
   },
   datasource: {
     // Provide a default value for CI/CD environments where the database URL is not set
     // This allows prisma generate to run without connecting to the database
-    url: env("DATABASE_URL") ?? "postgresql://postgres:postgres@localhost:5432/effectify",
+    url: databaseUrl,
   },
 })
📝 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
datasource: {
url: env("DATABASE_URL"),
// Provide a default value for CI/CD environments where the database URL is not set
// This allows prisma generate to run without connecting to the database
url: env("DATABASE_URL") ?? "postgresql://postgres:postgres@localhost:5432/effectify",
},
const databaseUrl =
env("DATABASE_URL") ??
(process.env.CI ? "postgresql://postgres:postgres@localhost:5432/effectify" : undefined)
if (!databaseUrl && !process.env.CI) {
throw new Error("DATABASE_URL is required outside CI")
}
export default defineConfig({
schema: "prisma/schema.prisma",
migrations: {
path: "prisma/migrations",
},
datasource: {
// Provide a default value for CI/CD environments where the database URL is not set
// This allows prisma generate to run without connecting to the database
url: databaseUrl,
},
})
🤖 Prompt for AI Agents
In `@apps/react-router-example/prisma.config.ts` around lines 11 - 15, The
datasource url fallback currently uses env("DATABASE_URL") ??
"postgresql://postgres:postgres@localhost:5432/..." which masks missing
DATABASE_URL in dev; change it to only apply the hardcoded fallback when running
in CI (e.g. when process.env.CI === "true" or a dedicated CI flag) so
local/machine runs fail fast; update the datasource.url expression to check
process.env.CI (or similar) and only return the localhost fallback in CI,
keeping the runtime guard in app/lib/prisma.ts intact.

})