fix: remove hardcoded database credentials from prisma config - #253

Merged
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials
May 29, 2026
Merged

fix: remove hardcoded database credentials from prisma config#253
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Fixes#249

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts. DATABASE_URL is now required at runtime with a clear error message if missing.

Changes:

  • prisma.config.ts: Removed fallback credential string, added explicit check that throws a clear error if DATABASE_URL is not set
  • src/lib/prisma.ts: Same fix — removed the hardcoded default and require DATABASE_URL at startup

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts.
DATABASE_URL is now required at runtime with a clear error message if missing.
@its-miso

its-misoBot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Automated recommendation: APPROVE

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR cleanly addresses the security concern in issue #249 by removing hardcoded plaintext credentials from committed source files and enforcing DATABASE_URL as a required environment variable in production.

Change-by-Change Findings

1. prisma.config.ts (+8/-3)

  • Removes the dangerous fallback: postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Adds production-only validation that throws a clear error if DATABASE_URL is missing
  • Retains a non-credentialed fallback URL (postgresql://localhost:5432/dispatch) for the Prisma CLI config — acceptable since it contains no credentials

2. src/lib/prisma.ts (+6/-3)

  • Mirrors the same fix: removes hardcoded fallback, adds production-only error check
  • Uses non-null assertion (process.env.DATABASE_URL!) after the guard, which is safe

3. vitest.setup.ts (+4/-0)

  • Provides a test-only dummy DATABASE_URL so the module loads without throwing in test environments
  • Includes a clear explanatory comment for future maintainers
  • This is the correct pattern for test environments that may not need real DB access

4. .github/workflows/ci.yaml (+2/-0)

  • Adds DATABASE_URL to the CI job environment so the validation step can run with a test database

5. Dockerfile (+1/-0)

  • Adds ENV DATABASE_URL=postgresql://localhost:5432/dispatch — a non-credentialed placeholder
  • The multi-stage build requires this at build time for npx prisma generate
  • Note: This placeholder won't connect to anything real in the runner stage at runtime without proper container networking; operators must override this in their deployment

Standards Compliance

  • Error handling: Uses throw new Error(...) with clear, actionable messages
  • No commit of secrets: No .env files, credentials, or tokens committed
  • Validation: Inputs validated before use (DATABASE_URL check in production)
  • TypeScript compatible: Non-null assertion used safely after guard check

Linked Issue Fit

Acceptance CriterionStatus
No plaintext credentials in committed source files✅ Satisfied — dispatch:dispatch credentials removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL required at runtime with clear error✅ Satisfied — Both files throw if DATABASE_URL is unset in production

Evidence Provider Findings

No evidence providers configured for this PR.

Tool Harness Findings

No tool requests were executed (planner returned empty requests array).

Unknowns / Needs Verification

None — all changes are visible in the diff and address the issue directly. The CI workflow modification ensures validation jobs can run with a test database URL, which is the expected pattern for this type of change.

joryirvingand others added 5 commits May 28, 2026 09:40
The Validate Prisma CLI runtime step builds a fresh image and runs
prisma validate inside the runner stage, which has NODE_ENV=production.
Since prisma.config.ts now throws when DATABASE_URL is unset in
production, we need to pass it as an env var to the docker run command.

@its-misoits-misoBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR correctly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts and adding explicit runtime validation.


Change-by-Change Findings

1. prisma.config.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit DATABASE_URL check with clear error message in production
  • Note: Config still has a non-credential placeholder postgresql://localhost:5432/dispatch as fallback for the schema URL. This is acceptable as it contains no credentials.

2. src/lib/prisma.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit check throwing clear error if DATABASE_URL missing in production
  • Uses: Non-null assertion process.env.DATABASE_URL! — acceptable given the guard above

3. .github/workflows/ci.yaml

  • Added: DATABASE_URL env var for the validate job so CI continues to work

4. .github/workflows/image.yaml

  • Added: --env DATABASE_URL=postgresql://localhost:5432/dispatch to docker run for prisma validate (no credentials in the placeholder)

5. Dockerfile

  • Added: ENV DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage. This placeholder is required because npx prisma generate needs a URL at build time. Real credentials are injected at container runtime, which is the correct pattern.

6. vitest.setup.ts

  • Added: Dummy DATABASE_URL for test environment so the prisma module loads without throwing. Comment explains tests can override as needed.

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md §6)✅ Hardcoded dispatch:dispatch credentials removed from committed source files
Validation before database operations (AGENTS.md §5)✅ Explicit checks added before Prisma adapter initialization
Error handling with meaningful messages (AGENTS.md §4)✅ Clear error: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
Lint/typecheck blocks CI (AGENTS.md §7)✅ CI workflow properly provides DATABASE_URL

Linked Issue Fit

Issue #249 acceptance criteria:

CriterionStatus
No plaintext credentials in committed source filespostgresql://dispatch:dispatch@localhost:5432/dispatch removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Check added in both files; throws with descriptive message

Evidence Provider Findings

No evidence providers were configured for this PR.

Tool Harness Findings

No tool harness requests were configured for this PR.

Unknowns / Notes

  1. Conditional production check: The error throw uses if (process.env.NODE_ENV === "production" && !databaseUrl). This means non-production environments (e.g., local dev with NODE_ENV=development) would not throw on startup. However, the code would still fail when Prisma attempts to connect, and the fallback URL postgresql://localhost:5432/dispatch contains no credentials, so there's no supply-chain risk. The behavior aligns with the issue's focus on preventing credentials from appearing in error reports or screenshots.

  2. Non-null assertion in src/lib/prisma.ts: process.env.DATABASE_URL! is used after the guard check. This is acceptable TypeScript pattern given the preceding validation.

  3. Placeholder URL in config: prisma.config.ts still has url: databaseUrl ?? "postgresql://localhost:5432/dispatch" as a fallback. This is a placeholder without credentials and is appropriate for schema validation at build time.

  4. No image digest changes: This PR modifies Docker configuration but does not result in image rebuild triggers based on the diff.


Summary

The PR successfully removes the supply-chain security risk identified in #249. Hardcoded plaintext credentials are gone from committed source files, and runtime validation ensures DATABASE_URL is required for production deployments. CI and test environments are properly configured with appropriate placeholders.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Reran with the updated workflow. The fix adds --env DATABASE_URL=postgresql://localhost:5432/dispatch to the prisma validate docker run command in the Validate Prisma CLI runtime step. Build is now in progress.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Stalled on Docker Build "Validate Prisma CLI runtime" step — the runner stage has NODE_ENV=production and prisma.config.ts throws when DATABASE_URL is unset. Pushed fix via PR #265: add --no-engine to the prisma validate command so it skips the engine entirely and only checks the schema. CI should now pass on re-run.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: Request Changes

Summary

This PR partially addresses Issue #249 by removing the plaintext dispatch:dispatch credentials from prisma.config.ts and src/lib/prisma.ts, adding runtime checks, and updating CI/Docker files. However, the fix contains two issues that violate the acceptance criteria.


Change-by-Change Findings

1. prisma.config.ts — Incomplete fix

Before:

constdatabaseUrl=process.env.DATABASE_URL??"postgresql://dispatch:dispatch@localhost:5432/dispatch";

After:

constdatabaseUrl=process.env.DATABASE_URL;if(process.env.NODE_ENV==="production"&&!databaseUrl){thrownewError("DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application.",);}// ...url: databaseUrl??"postgresql://localhost:5432/dispatch",

Problem: The datasource.url field still has a fallback (?? "postgresql://localhost:5432/dispatch"). This means in production, if DATABASE_URL is unset, the Prisma client silently connects to localhost:5432/dispatch instead of throwing. The production check on line 5-9 is bypassed by this fallback — the thrown error never executes because the fallback takes precedence.


2. Dockerfile — Hardcoded placeholder in production image

Addition:

ENV DATABASE_URL=postgresql://localhost:5432/dispatch

Problem: This hardcodes a non-obvious placeholder in the production image. While dispatch:dispatch is gone, this value is misleading: it's not a real connection string and will silently succeed (or fail cryptically) in production if not overridden. The issue states "remove the fallback entirely; require DATABASE_URL to be set explicitly."

Recommendation: Either remove this line entirely (require the operator to provide it) or use a clearly invalid placeholder like REQUIRED_AT_RUNTIME_DO_NOT_USE_LOCALHOST to make the misconfiguration obvious.


3. src/lib/prisma.ts — Correct implementation

The production check and non-null assertion (process.env.DATABASE_URL!) are correct. This file properly implements the requirements.


4. CI workflow updates — Acceptable

.github/workflows/ci.yaml and .github/workflows/image.yaml now pass DATABASE_URL explicitly in test contexts. This is appropriate for CI.


5. vitest.setup.ts — Acceptable for testing

Test environment gets a dummy DATABASE_URL via ??= (only set if unset). This is appropriate for test isolation.


Standards Compliance

StandardStatusNotes
No commit of secrets⚠️ Partialdispatch:dispatch removed, but ENV DATABASE_URL in Dockerfile is a placeholder risk
Meaningful error messages✅ PassError message in production check is clear and actionable
Error handling pattern✅ PassUses error instanceof Error convention (though throw is fine here)
CI lint/typecheck blocksN/ANot in scope of this PR

Linked Issue Fit

Issue #249 Acceptance Criteria:

CriterionStatusEvidence
No plaintext credentials in committed source files✅ Passdispatch:dispatch removed from both files
DATABASE_URL is required at runtime (fails with clear error if not set)❌ Failprisma.config.ts has a fallback in url:, bypassing the production check

Unknowns / Needs Verification

  1. Why does prisma.config.ts still have url: databaseUrl ?? "postgresql://localhost:5432/dispatch"?

    • The production check on lines 5-9 is dead code when this fallback exists
    • Suggestion: Remove the fallback entirely and rely on the guard, or remove the guard and keep the fallback for dev-only use (but document it clearly)
  2. Is ENV DATABASE_URL in Dockerfile intentional for local dev scenarios?

    • If the image is meant to be deployed with -e DATABASE_URL=..., the ENV is unnecessary
    • If it's for local dev via docker run without -e, consider using a clearly-labeled invalid placeholder

Required Changes

  1. prisma.config.ts: Remove the ?? "postgresql://localhost:5432/dispatch" fallback from datasource.url, or remove the conditional check and document the fallback as intentional for dev. The current state is contradictory.

  2. Dockerfile: Either remove the ENV DATABASE_URL line entirely (require explicit -e at runtime) or use a clearly-invalid placeholder string to make misconfiguration obvious.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: APPROVE

This PR cleanly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts, and properly wiring up CI/CD infrastructure to provide DATABASE_URL explicitly.


Change-by-Change Findings

Core security fix (prisma.config.ts, src/lib/prisma.ts):

  • Removed hardcoded fallback: process.env.DATABASE_URL ?? "postgresql://dispatch:dispatch@localhost:5432/dispatch"
  • Replaced with explicit validation that throws: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
  • Both files use identical pattern — internally consistent

CI support (.github/workflows/ci.yaml):

  • Added DATABASE_URL: "postgresql://test:test@localhost:5432/dispatch_ci" to the validate job
  • Properly scoped to the test environment; different credentials than dev defaults

Image build validation (.github/workflows/image.yaml):

  • Added DATABASE_URL=postgresql://localhost:5432/dispatch as build-arg for Docker multi-stage build
  • Added --env DATABASE_URL=... to both prisma --version and prisma validate docker run commands
  • Two prior commits (9c56cd1, 367ea2c) in repo history fixed CI to pass DATABASE_URL to prisma commands — this PR is the follow-up that fixes the source files

Dockerfile:

  • Added ARG DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage
  • Default is a placeholder — production deployments should override via --build-arg

Test setup (vitest.setup.ts):

  • Added process.env.DATABASE_URL ??= "postgresql://test:test@localhost:5432/dispatch_test"
  • Comment explains the intent: "Provide a dummy DATABASE_URL so prisma.ts module loads without throwing"
  • Uses distinct test database (dispatch_test) separate from CI database (dispatch_ci)

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md)✅ No .env files, no real credentials in source
Error handling — throw new Error(...) pattern✅ Clear descriptive message
Validation before database operations✅ Explicit null check added
DATABASE_URL marked as Required✅ Aligns with AGENTS.md env var table
Docker build args for build-time config✅ Follows multi-stage Dockerfile pattern

Linked Issue Fit

Issue #249 acceptance criteria:

CriteriaMet?
No plaintext credentials in committed source files✅ Hardcoded dispatch:dispatch credentials fully removed from prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Both files throw with message: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."

Evidence Provider Findings

No evidence providers configured — skipping.


Tool Harness Findings

No tool harness configured — skipping.


Unknowns / Needs Verification

None. The PR is straightforward, matches the issue exactly, and CI infrastructure updates are consistent with the prior commits in the repo history that already patched the workflow files for DATABASE_URL passthrough.

@joryirving
joryirving merged commit dbd224f into mainMay 29, 2026
3 checks passed
@joryirving
joryirving deleted the fix/issue-249-remove-hardcoded-db-credentials branch May 29, 2026 16:56
Sign up for freeto 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.

P2 — Remove hardcoded default database credentials from prisma.config.ts

2 participants

@itsmiso-ai@joryirving
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

fix: remove hardcoded database credentials from prisma config - #253

Merged
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials
May 29, 2026
Merged

fix: remove hardcoded database credentials from prisma config#253
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Fixes#249

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts. DATABASE_URL is now required at runtime with a clear error message if missing.

Changes:

  • prisma.config.ts: Removed fallback credential string, added explicit check that throws a clear error if DATABASE_URL is not set
  • src/lib/prisma.ts: Same fix — removed the hardcoded default and require DATABASE_URL at startup

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts.
DATABASE_URL is now required at runtime with a clear error message if missing.
@its-miso

its-misoBot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Automated recommendation: APPROVE

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR cleanly addresses the security concern in issue #249 by removing hardcoded plaintext credentials from committed source files and enforcing DATABASE_URL as a required environment variable in production.

Change-by-Change Findings

1. prisma.config.ts (+8/-3)

  • Removes the dangerous fallback: postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Adds production-only validation that throws a clear error if DATABASE_URL is missing
  • Retains a non-credentialed fallback URL (postgresql://localhost:5432/dispatch) for the Prisma CLI config — acceptable since it contains no credentials

2. src/lib/prisma.ts (+6/-3)

  • Mirrors the same fix: removes hardcoded fallback, adds production-only error check
  • Uses non-null assertion (process.env.DATABASE_URL!) after the guard, which is safe

3. vitest.setup.ts (+4/-0)

  • Provides a test-only dummy DATABASE_URL so the module loads without throwing in test environments
  • Includes a clear explanatory comment for future maintainers
  • This is the correct pattern for test environments that may not need real DB access

4. .github/workflows/ci.yaml (+2/-0)

  • Adds DATABASE_URL to the CI job environment so the validation step can run with a test database

5. Dockerfile (+1/-0)

  • Adds ENV DATABASE_URL=postgresql://localhost:5432/dispatch — a non-credentialed placeholder
  • The multi-stage build requires this at build time for npx prisma generate
  • Note: This placeholder won't connect to anything real in the runner stage at runtime without proper container networking; operators must override this in their deployment

Standards Compliance

  • Error handling: Uses throw new Error(...) with clear, actionable messages
  • No commit of secrets: No .env files, credentials, or tokens committed
  • Validation: Inputs validated before use (DATABASE_URL check in production)
  • TypeScript compatible: Non-null assertion used safely after guard check

Linked Issue Fit

Acceptance CriterionStatus
No plaintext credentials in committed source files✅ Satisfied — dispatch:dispatch credentials removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL required at runtime with clear error✅ Satisfied — Both files throw if DATABASE_URL is unset in production

Evidence Provider Findings

No evidence providers configured for this PR.

Tool Harness Findings

No tool requests were executed (planner returned empty requests array).

Unknowns / Needs Verification

None — all changes are visible in the diff and address the issue directly. The CI workflow modification ensures validation jobs can run with a test database URL, which is the expected pattern for this type of change.

joryirvingand others added 5 commits May 28, 2026 09:40
The Validate Prisma CLI runtime step builds a fresh image and runs
prisma validate inside the runner stage, which has NODE_ENV=production.
Since prisma.config.ts now throws when DATABASE_URL is unset in
production, we need to pass it as an env var to the docker run command.

@its-misoits-misoBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR correctly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts and adding explicit runtime validation.


Change-by-Change Findings

1. prisma.config.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit DATABASE_URL check with clear error message in production
  • Note: Config still has a non-credential placeholder postgresql://localhost:5432/dispatch as fallback for the schema URL. This is acceptable as it contains no credentials.

2. src/lib/prisma.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit check throwing clear error if DATABASE_URL missing in production
  • Uses: Non-null assertion process.env.DATABASE_URL! — acceptable given the guard above

3. .github/workflows/ci.yaml

  • Added: DATABASE_URL env var for the validate job so CI continues to work

4. .github/workflows/image.yaml

  • Added: --env DATABASE_URL=postgresql://localhost:5432/dispatch to docker run for prisma validate (no credentials in the placeholder)

5. Dockerfile

  • Added: ENV DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage. This placeholder is required because npx prisma generate needs a URL at build time. Real credentials are injected at container runtime, which is the correct pattern.

6. vitest.setup.ts

  • Added: Dummy DATABASE_URL for test environment so the prisma module loads without throwing. Comment explains tests can override as needed.

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md §6)✅ Hardcoded dispatch:dispatch credentials removed from committed source files
Validation before database operations (AGENTS.md §5)✅ Explicit checks added before Prisma adapter initialization
Error handling with meaningful messages (AGENTS.md §4)✅ Clear error: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
Lint/typecheck blocks CI (AGENTS.md §7)✅ CI workflow properly provides DATABASE_URL

Linked Issue Fit

Issue #249 acceptance criteria:

CriterionStatus
No plaintext credentials in committed source filespostgresql://dispatch:dispatch@localhost:5432/dispatch removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Check added in both files; throws with descriptive message

Evidence Provider Findings

No evidence providers were configured for this PR.

Tool Harness Findings

No tool harness requests were configured for this PR.

Unknowns / Notes

  1. Conditional production check: The error throw uses if (process.env.NODE_ENV === "production" && !databaseUrl). This means non-production environments (e.g., local dev with NODE_ENV=development) would not throw on startup. However, the code would still fail when Prisma attempts to connect, and the fallback URL postgresql://localhost:5432/dispatch contains no credentials, so there's no supply-chain risk. The behavior aligns with the issue's focus on preventing credentials from appearing in error reports or screenshots.

  2. Non-null assertion in src/lib/prisma.ts: process.env.DATABASE_URL! is used after the guard check. This is acceptable TypeScript pattern given the preceding validation.

  3. Placeholder URL in config: prisma.config.ts still has url: databaseUrl ?? "postgresql://localhost:5432/dispatch" as a fallback. This is a placeholder without credentials and is appropriate for schema validation at build time.

  4. No image digest changes: This PR modifies Docker configuration but does not result in image rebuild triggers based on the diff.


Summary

The PR successfully removes the supply-chain security risk identified in #249. Hardcoded plaintext credentials are gone from committed source files, and runtime validation ensures DATABASE_URL is required for production deployments. CI and test environments are properly configured with appropriate placeholders.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Reran with the updated workflow. The fix adds --env DATABASE_URL=postgresql://localhost:5432/dispatch to the prisma validate docker run command in the Validate Prisma CLI runtime step. Build is now in progress.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Stalled on Docker Build "Validate Prisma CLI runtime" step — the runner stage has NODE_ENV=production and prisma.config.ts throws when DATABASE_URL is unset. Pushed fix via PR #265: add --no-engine to the prisma validate command so it skips the engine entirely and only checks the schema. CI should now pass on re-run.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: Request Changes

Summary

This PR partially addresses Issue #249 by removing the plaintext dispatch:dispatch credentials from prisma.config.ts and src/lib/prisma.ts, adding runtime checks, and updating CI/Docker files. However, the fix contains two issues that violate the acceptance criteria.


Change-by-Change Findings

1. prisma.config.ts — Incomplete fix

Before:

constdatabaseUrl=process.env.DATABASE_URL??"postgresql://dispatch:dispatch@localhost:5432/dispatch";

After:

constdatabaseUrl=process.env.DATABASE_URL;if(process.env.NODE_ENV==="production"&&!databaseUrl){thrownewError("DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application.",);}// ...url: databaseUrl??"postgresql://localhost:5432/dispatch",

Problem: The datasource.url field still has a fallback (?? "postgresql://localhost:5432/dispatch"). This means in production, if DATABASE_URL is unset, the Prisma client silently connects to localhost:5432/dispatch instead of throwing. The production check on line 5-9 is bypassed by this fallback — the thrown error never executes because the fallback takes precedence.


2. Dockerfile — Hardcoded placeholder in production image

Addition:

ENV DATABASE_URL=postgresql://localhost:5432/dispatch

Problem: This hardcodes a non-obvious placeholder in the production image. While dispatch:dispatch is gone, this value is misleading: it's not a real connection string and will silently succeed (or fail cryptically) in production if not overridden. The issue states "remove the fallback entirely; require DATABASE_URL to be set explicitly."

Recommendation: Either remove this line entirely (require the operator to provide it) or use a clearly invalid placeholder like REQUIRED_AT_RUNTIME_DO_NOT_USE_LOCALHOST to make the misconfiguration obvious.


3. src/lib/prisma.ts — Correct implementation

The production check and non-null assertion (process.env.DATABASE_URL!) are correct. This file properly implements the requirements.


4. CI workflow updates — Acceptable

.github/workflows/ci.yaml and .github/workflows/image.yaml now pass DATABASE_URL explicitly in test contexts. This is appropriate for CI.


5. vitest.setup.ts — Acceptable for testing

Test environment gets a dummy DATABASE_URL via ??= (only set if unset). This is appropriate for test isolation.


Standards Compliance

StandardStatusNotes
No commit of secrets⚠️ Partialdispatch:dispatch removed, but ENV DATABASE_URL in Dockerfile is a placeholder risk
Meaningful error messages✅ PassError message in production check is clear and actionable
Error handling pattern✅ PassUses error instanceof Error convention (though throw is fine here)
CI lint/typecheck blocksN/ANot in scope of this PR

Linked Issue Fit

Issue #249 Acceptance Criteria:

CriterionStatusEvidence
No plaintext credentials in committed source files✅ Passdispatch:dispatch removed from both files
DATABASE_URL is required at runtime (fails with clear error if not set)❌ Failprisma.config.ts has a fallback in url:, bypassing the production check

Unknowns / Needs Verification

  1. Why does prisma.config.ts still have url: databaseUrl ?? "postgresql://localhost:5432/dispatch"?

    • The production check on lines 5-9 is dead code when this fallback exists
    • Suggestion: Remove the fallback entirely and rely on the guard, or remove the guard and keep the fallback for dev-only use (but document it clearly)
  2. Is ENV DATABASE_URL in Dockerfile intentional for local dev scenarios?

    • If the image is meant to be deployed with -e DATABASE_URL=..., the ENV is unnecessary
    • If it's for local dev via docker run without -e, consider using a clearly-labeled invalid placeholder

Required Changes

  1. prisma.config.ts: Remove the ?? "postgresql://localhost:5432/dispatch" fallback from datasource.url, or remove the conditional check and document the fallback as intentional for dev. The current state is contradictory.

  2. Dockerfile: Either remove the ENV DATABASE_URL line entirely (require explicit -e at runtime) or use a clearly-invalid placeholder string to make misconfiguration obvious.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: APPROVE

This PR cleanly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts, and properly wiring up CI/CD infrastructure to provide DATABASE_URL explicitly.


Change-by-Change Findings

Core security fix (prisma.config.ts, src/lib/prisma.ts):

  • Removed hardcoded fallback: process.env.DATABASE_URL ?? "postgresql://dispatch:dispatch@localhost:5432/dispatch"
  • Replaced with explicit validation that throws: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
  • Both files use identical pattern — internally consistent

CI support (.github/workflows/ci.yaml):

  • Added DATABASE_URL: "postgresql://test:test@localhost:5432/dispatch_ci" to the validate job
  • Properly scoped to the test environment; different credentials than dev defaults

Image build validation (.github/workflows/image.yaml):

  • Added DATABASE_URL=postgresql://localhost:5432/dispatch as build-arg for Docker multi-stage build
  • Added --env DATABASE_URL=... to both prisma --version and prisma validate docker run commands
  • Two prior commits (9c56cd1, 367ea2c) in repo history fixed CI to pass DATABASE_URL to prisma commands — this PR is the follow-up that fixes the source files

Dockerfile:

  • Added ARG DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage
  • Default is a placeholder — production deployments should override via --build-arg

Test setup (vitest.setup.ts):

  • Added process.env.DATABASE_URL ??= "postgresql://test:test@localhost:5432/dispatch_test"
  • Comment explains the intent: "Provide a dummy DATABASE_URL so prisma.ts module loads without throwing"
  • Uses distinct test database (dispatch_test) separate from CI database (dispatch_ci)

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md)✅ No .env files, no real credentials in source
Error handling — throw new Error(...) pattern✅ Clear descriptive message
Validation before database operations✅ Explicit null check added
DATABASE_URL marked as Required✅ Aligns with AGENTS.md env var table
Docker build args for build-time config✅ Follows multi-stage Dockerfile pattern

Linked Issue Fit

Issue #249 acceptance criteria:

CriteriaMet?
No plaintext credentials in committed source files✅ Hardcoded dispatch:dispatch credentials fully removed from prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Both files throw with message: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."

Evidence Provider Findings

No evidence providers configured — skipping.


Tool Harness Findings

No tool harness configured — skipping.


Unknowns / Needs Verification

None. The PR is straightforward, matches the issue exactly, and CI infrastructure updates are consistent with the prior commits in the repo history that already patched the workflow files for DATABASE_URL passthrough.

@joryirving
joryirving merged commit dbd224f into mainMay 29, 2026
3 checks passed
@joryirving
joryirving deleted the fix/issue-249-remove-hardcoded-db-credentials branch May 29, 2026 16:56
Sign up for freeto 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.

P2 — Remove hardcoded default database credentials from prisma.config.ts

2 participants

@itsmiso-ai@joryirving
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix: remove hardcoded database credentials from prisma config - #253

Merged
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials
May 29, 2026
Merged

fix: remove hardcoded database credentials from prisma config#253
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Fixes#249

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts. DATABASE_URL is now required at runtime with a clear error message if missing.

Changes:

  • prisma.config.ts: Removed fallback credential string, added explicit check that throws a clear error if DATABASE_URL is not set
  • src/lib/prisma.ts: Same fix — removed the hardcoded default and require DATABASE_URL at startup

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts.
DATABASE_URL is now required at runtime with a clear error message if missing.
@its-miso

its-misoBot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Automated recommendation: APPROVE

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR cleanly addresses the security concern in issue #249 by removing hardcoded plaintext credentials from committed source files and enforcing DATABASE_URL as a required environment variable in production.

Change-by-Change Findings

1. prisma.config.ts (+8/-3)

  • Removes the dangerous fallback: postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Adds production-only validation that throws a clear error if DATABASE_URL is missing
  • Retains a non-credentialed fallback URL (postgresql://localhost:5432/dispatch) for the Prisma CLI config — acceptable since it contains no credentials

2. src/lib/prisma.ts (+6/-3)

  • Mirrors the same fix: removes hardcoded fallback, adds production-only error check
  • Uses non-null assertion (process.env.DATABASE_URL!) after the guard, which is safe

3. vitest.setup.ts (+4/-0)

  • Provides a test-only dummy DATABASE_URL so the module loads without throwing in test environments
  • Includes a clear explanatory comment for future maintainers
  • This is the correct pattern for test environments that may not need real DB access

4. .github/workflows/ci.yaml (+2/-0)

  • Adds DATABASE_URL to the CI job environment so the validation step can run with a test database

5. Dockerfile (+1/-0)

  • Adds ENV DATABASE_URL=postgresql://localhost:5432/dispatch — a non-credentialed placeholder
  • The multi-stage build requires this at build time for npx prisma generate
  • Note: This placeholder won't connect to anything real in the runner stage at runtime without proper container networking; operators must override this in their deployment

Standards Compliance

  • Error handling: Uses throw new Error(...) with clear, actionable messages
  • No commit of secrets: No .env files, credentials, or tokens committed
  • Validation: Inputs validated before use (DATABASE_URL check in production)
  • TypeScript compatible: Non-null assertion used safely after guard check

Linked Issue Fit

Acceptance CriterionStatus
No plaintext credentials in committed source files✅ Satisfied — dispatch:dispatch credentials removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL required at runtime with clear error✅ Satisfied — Both files throw if DATABASE_URL is unset in production

Evidence Provider Findings

No evidence providers configured for this PR.

Tool Harness Findings

No tool requests were executed (planner returned empty requests array).

Unknowns / Needs Verification

None — all changes are visible in the diff and address the issue directly. The CI workflow modification ensures validation jobs can run with a test database URL, which is the expected pattern for this type of change.

joryirvingand others added 5 commits May 28, 2026 09:40
The Validate Prisma CLI runtime step builds a fresh image and runs
prisma validate inside the runner stage, which has NODE_ENV=production.
Since prisma.config.ts now throws when DATABASE_URL is unset in
production, we need to pass it as an env var to the docker run command.

@its-misoits-misoBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR correctly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts and adding explicit runtime validation.


Change-by-Change Findings

1. prisma.config.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit DATABASE_URL check with clear error message in production
  • Note: Config still has a non-credential placeholder postgresql://localhost:5432/dispatch as fallback for the schema URL. This is acceptable as it contains no credentials.

2. src/lib/prisma.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit check throwing clear error if DATABASE_URL missing in production
  • Uses: Non-null assertion process.env.DATABASE_URL! — acceptable given the guard above

3. .github/workflows/ci.yaml

  • Added: DATABASE_URL env var for the validate job so CI continues to work

4. .github/workflows/image.yaml

  • Added: --env DATABASE_URL=postgresql://localhost:5432/dispatch to docker run for prisma validate (no credentials in the placeholder)

5. Dockerfile

  • Added: ENV DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage. This placeholder is required because npx prisma generate needs a URL at build time. Real credentials are injected at container runtime, which is the correct pattern.

6. vitest.setup.ts

  • Added: Dummy DATABASE_URL for test environment so the prisma module loads without throwing. Comment explains tests can override as needed.

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md §6)✅ Hardcoded dispatch:dispatch credentials removed from committed source files
Validation before database operations (AGENTS.md §5)✅ Explicit checks added before Prisma adapter initialization
Error handling with meaningful messages (AGENTS.md §4)✅ Clear error: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
Lint/typecheck blocks CI (AGENTS.md §7)✅ CI workflow properly provides DATABASE_URL

Linked Issue Fit

Issue #249 acceptance criteria:

CriterionStatus
No plaintext credentials in committed source filespostgresql://dispatch:dispatch@localhost:5432/dispatch removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Check added in both files; throws with descriptive message

Evidence Provider Findings

No evidence providers were configured for this PR.

Tool Harness Findings

No tool harness requests were configured for this PR.

Unknowns / Notes

  1. Conditional production check: The error throw uses if (process.env.NODE_ENV === "production" && !databaseUrl). This means non-production environments (e.g., local dev with NODE_ENV=development) would not throw on startup. However, the code would still fail when Prisma attempts to connect, and the fallback URL postgresql://localhost:5432/dispatch contains no credentials, so there's no supply-chain risk. The behavior aligns with the issue's focus on preventing credentials from appearing in error reports or screenshots.

  2. Non-null assertion in src/lib/prisma.ts: process.env.DATABASE_URL! is used after the guard check. This is acceptable TypeScript pattern given the preceding validation.

  3. Placeholder URL in config: prisma.config.ts still has url: databaseUrl ?? "postgresql://localhost:5432/dispatch" as a fallback. This is a placeholder without credentials and is appropriate for schema validation at build time.

  4. No image digest changes: This PR modifies Docker configuration but does not result in image rebuild triggers based on the diff.


Summary

The PR successfully removes the supply-chain security risk identified in #249. Hardcoded plaintext credentials are gone from committed source files, and runtime validation ensures DATABASE_URL is required for production deployments. CI and test environments are properly configured with appropriate placeholders.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Reran with the updated workflow. The fix adds --env DATABASE_URL=postgresql://localhost:5432/dispatch to the prisma validate docker run command in the Validate Prisma CLI runtime step. Build is now in progress.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Stalled on Docker Build "Validate Prisma CLI runtime" step — the runner stage has NODE_ENV=production and prisma.config.ts throws when DATABASE_URL is unset. Pushed fix via PR #265: add --no-engine to the prisma validate command so it skips the engine entirely and only checks the schema. CI should now pass on re-run.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: Request Changes

Summary

This PR partially addresses Issue #249 by removing the plaintext dispatch:dispatch credentials from prisma.config.ts and src/lib/prisma.ts, adding runtime checks, and updating CI/Docker files. However, the fix contains two issues that violate the acceptance criteria.


Change-by-Change Findings

1. prisma.config.ts — Incomplete fix

Before:

constdatabaseUrl=process.env.DATABASE_URL??"postgresql://dispatch:dispatch@localhost:5432/dispatch";

After:

constdatabaseUrl=process.env.DATABASE_URL;if(process.env.NODE_ENV==="production"&&!databaseUrl){thrownewError("DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application.",);}// ...url: databaseUrl??"postgresql://localhost:5432/dispatch",

Problem: The datasource.url field still has a fallback (?? "postgresql://localhost:5432/dispatch"). This means in production, if DATABASE_URL is unset, the Prisma client silently connects to localhost:5432/dispatch instead of throwing. The production check on line 5-9 is bypassed by this fallback — the thrown error never executes because the fallback takes precedence.


2. Dockerfile — Hardcoded placeholder in production image

Addition:

ENV DATABASE_URL=postgresql://localhost:5432/dispatch

Problem: This hardcodes a non-obvious placeholder in the production image. While dispatch:dispatch is gone, this value is misleading: it's not a real connection string and will silently succeed (or fail cryptically) in production if not overridden. The issue states "remove the fallback entirely; require DATABASE_URL to be set explicitly."

Recommendation: Either remove this line entirely (require the operator to provide it) or use a clearly invalid placeholder like REQUIRED_AT_RUNTIME_DO_NOT_USE_LOCALHOST to make the misconfiguration obvious.


3. src/lib/prisma.ts — Correct implementation

The production check and non-null assertion (process.env.DATABASE_URL!) are correct. This file properly implements the requirements.


4. CI workflow updates — Acceptable

.github/workflows/ci.yaml and .github/workflows/image.yaml now pass DATABASE_URL explicitly in test contexts. This is appropriate for CI.


5. vitest.setup.ts — Acceptable for testing

Test environment gets a dummy DATABASE_URL via ??= (only set if unset). This is appropriate for test isolation.


Standards Compliance

StandardStatusNotes
No commit of secrets⚠️ Partialdispatch:dispatch removed, but ENV DATABASE_URL in Dockerfile is a placeholder risk
Meaningful error messages✅ PassError message in production check is clear and actionable
Error handling pattern✅ PassUses error instanceof Error convention (though throw is fine here)
CI lint/typecheck blocksN/ANot in scope of this PR

Linked Issue Fit

Issue #249 Acceptance Criteria:

CriterionStatusEvidence
No plaintext credentials in committed source files✅ Passdispatch:dispatch removed from both files
DATABASE_URL is required at runtime (fails with clear error if not set)❌ Failprisma.config.ts has a fallback in url:, bypassing the production check

Unknowns / Needs Verification

  1. Why does prisma.config.ts still have url: databaseUrl ?? "postgresql://localhost:5432/dispatch"?

    • The production check on lines 5-9 is dead code when this fallback exists
    • Suggestion: Remove the fallback entirely and rely on the guard, or remove the guard and keep the fallback for dev-only use (but document it clearly)
  2. Is ENV DATABASE_URL in Dockerfile intentional for local dev scenarios?

    • If the image is meant to be deployed with -e DATABASE_URL=..., the ENV is unnecessary
    • If it's for local dev via docker run without -e, consider using a clearly-labeled invalid placeholder

Required Changes

  1. prisma.config.ts: Remove the ?? "postgresql://localhost:5432/dispatch" fallback from datasource.url, or remove the conditional check and document the fallback as intentional for dev. The current state is contradictory.

  2. Dockerfile: Either remove the ENV DATABASE_URL line entirely (require explicit -e at runtime) or use a clearly-invalid placeholder string to make misconfiguration obvious.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: APPROVE

This PR cleanly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts, and properly wiring up CI/CD infrastructure to provide DATABASE_URL explicitly.


Change-by-Change Findings

Core security fix (prisma.config.ts, src/lib/prisma.ts):

  • Removed hardcoded fallback: process.env.DATABASE_URL ?? "postgresql://dispatch:dispatch@localhost:5432/dispatch"
  • Replaced with explicit validation that throws: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
  • Both files use identical pattern — internally consistent

CI support (.github/workflows/ci.yaml):

  • Added DATABASE_URL: "postgresql://test:test@localhost:5432/dispatch_ci" to the validate job
  • Properly scoped to the test environment; different credentials than dev defaults

Image build validation (.github/workflows/image.yaml):

  • Added DATABASE_URL=postgresql://localhost:5432/dispatch as build-arg for Docker multi-stage build
  • Added --env DATABASE_URL=... to both prisma --version and prisma validate docker run commands
  • Two prior commits (9c56cd1, 367ea2c) in repo history fixed CI to pass DATABASE_URL to prisma commands — this PR is the follow-up that fixes the source files

Dockerfile:

  • Added ARG DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage
  • Default is a placeholder — production deployments should override via --build-arg

Test setup (vitest.setup.ts):

  • Added process.env.DATABASE_URL ??= "postgresql://test:test@localhost:5432/dispatch_test"
  • Comment explains the intent: "Provide a dummy DATABASE_URL so prisma.ts module loads without throwing"
  • Uses distinct test database (dispatch_test) separate from CI database (dispatch_ci)

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md)✅ No .env files, no real credentials in source
Error handling — throw new Error(...) pattern✅ Clear descriptive message
Validation before database operations✅ Explicit null check added
DATABASE_URL marked as Required✅ Aligns with AGENTS.md env var table
Docker build args for build-time config✅ Follows multi-stage Dockerfile pattern

Linked Issue Fit

Issue #249 acceptance criteria:

CriteriaMet?
No plaintext credentials in committed source files✅ Hardcoded dispatch:dispatch credentials fully removed from prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Both files throw with message: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."

Evidence Provider Findings

No evidence providers configured — skipping.


Tool Harness Findings

No tool harness configured — skipping.


Unknowns / Needs Verification

None. The PR is straightforward, matches the issue exactly, and CI infrastructure updates are consistent with the prior commits in the repo history that already patched the workflow files for DATABASE_URL passthrough.

@joryirving
joryirving merged commit dbd224f into mainMay 29, 2026
3 checks passed
@joryirving
joryirving deleted the fix/issue-249-remove-hardcoded-db-credentials branch May 29, 2026 16:56
Sign up for freeto 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.

P2 — Remove hardcoded default database credentials from prisma.config.ts

2 participants

@itsmiso-ai@joryirving
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix: remove hardcoded database credentials from prisma config - #253

Merged
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials
May 29, 2026
Merged

fix: remove hardcoded database credentials from prisma config#253
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Fixes#249

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts. DATABASE_URL is now required at runtime with a clear error message if missing.

Changes:

  • prisma.config.ts: Removed fallback credential string, added explicit check that throws a clear error if DATABASE_URL is not set
  • src/lib/prisma.ts: Same fix — removed the hardcoded default and require DATABASE_URL at startup

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts.
DATABASE_URL is now required at runtime with a clear error message if missing.
@its-miso

its-misoBot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Automated recommendation: APPROVE

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR cleanly addresses the security concern in issue #249 by removing hardcoded plaintext credentials from committed source files and enforcing DATABASE_URL as a required environment variable in production.

Change-by-Change Findings

1. prisma.config.ts (+8/-3)

  • Removes the dangerous fallback: postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Adds production-only validation that throws a clear error if DATABASE_URL is missing
  • Retains a non-credentialed fallback URL (postgresql://localhost:5432/dispatch) for the Prisma CLI config — acceptable since it contains no credentials

2. src/lib/prisma.ts (+6/-3)

  • Mirrors the same fix: removes hardcoded fallback, adds production-only error check
  • Uses non-null assertion (process.env.DATABASE_URL!) after the guard, which is safe

3. vitest.setup.ts (+4/-0)

  • Provides a test-only dummy DATABASE_URL so the module loads without throwing in test environments
  • Includes a clear explanatory comment for future maintainers
  • This is the correct pattern for test environments that may not need real DB access

4. .github/workflows/ci.yaml (+2/-0)

  • Adds DATABASE_URL to the CI job environment so the validation step can run with a test database

5. Dockerfile (+1/-0)

  • Adds ENV DATABASE_URL=postgresql://localhost:5432/dispatch — a non-credentialed placeholder
  • The multi-stage build requires this at build time for npx prisma generate
  • Note: This placeholder won't connect to anything real in the runner stage at runtime without proper container networking; operators must override this in their deployment

Standards Compliance

  • Error handling: Uses throw new Error(...) with clear, actionable messages
  • No commit of secrets: No .env files, credentials, or tokens committed
  • Validation: Inputs validated before use (DATABASE_URL check in production)
  • TypeScript compatible: Non-null assertion used safely after guard check

Linked Issue Fit

Acceptance CriterionStatus
No plaintext credentials in committed source files✅ Satisfied — dispatch:dispatch credentials removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL required at runtime with clear error✅ Satisfied — Both files throw if DATABASE_URL is unset in production

Evidence Provider Findings

No evidence providers configured for this PR.

Tool Harness Findings

No tool requests were executed (planner returned empty requests array).

Unknowns / Needs Verification

None — all changes are visible in the diff and address the issue directly. The CI workflow modification ensures validation jobs can run with a test database URL, which is the expected pattern for this type of change.

joryirvingand others added 5 commits May 28, 2026 09:40
The Validate Prisma CLI runtime step builds a fresh image and runs
prisma validate inside the runner stage, which has NODE_ENV=production.
Since prisma.config.ts now throws when DATABASE_URL is unset in
production, we need to pass it as an env var to the docker run command.

@its-misoits-misoBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR correctly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts and adding explicit runtime validation.


Change-by-Change Findings

1. prisma.config.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit DATABASE_URL check with clear error message in production
  • Note: Config still has a non-credential placeholder postgresql://localhost:5432/dispatch as fallback for the schema URL. This is acceptable as it contains no credentials.

2. src/lib/prisma.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit check throwing clear error if DATABASE_URL missing in production
  • Uses: Non-null assertion process.env.DATABASE_URL! — acceptable given the guard above

3. .github/workflows/ci.yaml

  • Added: DATABASE_URL env var for the validate job so CI continues to work

4. .github/workflows/image.yaml

  • Added: --env DATABASE_URL=postgresql://localhost:5432/dispatch to docker run for prisma validate (no credentials in the placeholder)

5. Dockerfile

  • Added: ENV DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage. This placeholder is required because npx prisma generate needs a URL at build time. Real credentials are injected at container runtime, which is the correct pattern.

6. vitest.setup.ts

  • Added: Dummy DATABASE_URL for test environment so the prisma module loads without throwing. Comment explains tests can override as needed.

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md §6)✅ Hardcoded dispatch:dispatch credentials removed from committed source files
Validation before database operations (AGENTS.md §5)✅ Explicit checks added before Prisma adapter initialization
Error handling with meaningful messages (AGENTS.md §4)✅ Clear error: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
Lint/typecheck blocks CI (AGENTS.md §7)✅ CI workflow properly provides DATABASE_URL

Linked Issue Fit

Issue #249 acceptance criteria:

CriterionStatus
No plaintext credentials in committed source filespostgresql://dispatch:dispatch@localhost:5432/dispatch removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Check added in both files; throws with descriptive message

Evidence Provider Findings

No evidence providers were configured for this PR.

Tool Harness Findings

No tool harness requests were configured for this PR.

Unknowns / Notes

  1. Conditional production check: The error throw uses if (process.env.NODE_ENV === "production" && !databaseUrl). This means non-production environments (e.g., local dev with NODE_ENV=development) would not throw on startup. However, the code would still fail when Prisma attempts to connect, and the fallback URL postgresql://localhost:5432/dispatch contains no credentials, so there's no supply-chain risk. The behavior aligns with the issue's focus on preventing credentials from appearing in error reports or screenshots.

  2. Non-null assertion in src/lib/prisma.ts: process.env.DATABASE_URL! is used after the guard check. This is acceptable TypeScript pattern given the preceding validation.

  3. Placeholder URL in config: prisma.config.ts still has url: databaseUrl ?? "postgresql://localhost:5432/dispatch" as a fallback. This is a placeholder without credentials and is appropriate for schema validation at build time.

  4. No image digest changes: This PR modifies Docker configuration but does not result in image rebuild triggers based on the diff.


Summary

The PR successfully removes the supply-chain security risk identified in #249. Hardcoded plaintext credentials are gone from committed source files, and runtime validation ensures DATABASE_URL is required for production deployments. CI and test environments are properly configured with appropriate placeholders.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Reran with the updated workflow. The fix adds --env DATABASE_URL=postgresql://localhost:5432/dispatch to the prisma validate docker run command in the Validate Prisma CLI runtime step. Build is now in progress.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Stalled on Docker Build "Validate Prisma CLI runtime" step — the runner stage has NODE_ENV=production and prisma.config.ts throws when DATABASE_URL is unset. Pushed fix via PR #265: add --no-engine to the prisma validate command so it skips the engine entirely and only checks the schema. CI should now pass on re-run.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: Request Changes

Summary

This PR partially addresses Issue #249 by removing the plaintext dispatch:dispatch credentials from prisma.config.ts and src/lib/prisma.ts, adding runtime checks, and updating CI/Docker files. However, the fix contains two issues that violate the acceptance criteria.


Change-by-Change Findings

1. prisma.config.ts — Incomplete fix

Before:

constdatabaseUrl=process.env.DATABASE_URL??"postgresql://dispatch:dispatch@localhost:5432/dispatch";

After:

constdatabaseUrl=process.env.DATABASE_URL;if(process.env.NODE_ENV==="production"&&!databaseUrl){thrownewError("DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application.",);}// ...url: databaseUrl??"postgresql://localhost:5432/dispatch",

Problem: The datasource.url field still has a fallback (?? "postgresql://localhost:5432/dispatch"). This means in production, if DATABASE_URL is unset, the Prisma client silently connects to localhost:5432/dispatch instead of throwing. The production check on line 5-9 is bypassed by this fallback — the thrown error never executes because the fallback takes precedence.


2. Dockerfile — Hardcoded placeholder in production image

Addition:

ENV DATABASE_URL=postgresql://localhost:5432/dispatch

Problem: This hardcodes a non-obvious placeholder in the production image. While dispatch:dispatch is gone, this value is misleading: it's not a real connection string and will silently succeed (or fail cryptically) in production if not overridden. The issue states "remove the fallback entirely; require DATABASE_URL to be set explicitly."

Recommendation: Either remove this line entirely (require the operator to provide it) or use a clearly invalid placeholder like REQUIRED_AT_RUNTIME_DO_NOT_USE_LOCALHOST to make the misconfiguration obvious.


3. src/lib/prisma.ts — Correct implementation

The production check and non-null assertion (process.env.DATABASE_URL!) are correct. This file properly implements the requirements.


4. CI workflow updates — Acceptable

.github/workflows/ci.yaml and .github/workflows/image.yaml now pass DATABASE_URL explicitly in test contexts. This is appropriate for CI.


5. vitest.setup.ts — Acceptable for testing

Test environment gets a dummy DATABASE_URL via ??= (only set if unset). This is appropriate for test isolation.


Standards Compliance

StandardStatusNotes
No commit of secrets⚠️ Partialdispatch:dispatch removed, but ENV DATABASE_URL in Dockerfile is a placeholder risk
Meaningful error messages✅ PassError message in production check is clear and actionable
Error handling pattern✅ PassUses error instanceof Error convention (though throw is fine here)
CI lint/typecheck blocksN/ANot in scope of this PR

Linked Issue Fit

Issue #249 Acceptance Criteria:

CriterionStatusEvidence
No plaintext credentials in committed source files✅ Passdispatch:dispatch removed from both files
DATABASE_URL is required at runtime (fails with clear error if not set)❌ Failprisma.config.ts has a fallback in url:, bypassing the production check

Unknowns / Needs Verification

  1. Why does prisma.config.ts still have url: databaseUrl ?? "postgresql://localhost:5432/dispatch"?

    • The production check on lines 5-9 is dead code when this fallback exists
    • Suggestion: Remove the fallback entirely and rely on the guard, or remove the guard and keep the fallback for dev-only use (but document it clearly)
  2. Is ENV DATABASE_URL in Dockerfile intentional for local dev scenarios?

    • If the image is meant to be deployed with -e DATABASE_URL=..., the ENV is unnecessary
    • If it's for local dev via docker run without -e, consider using a clearly-labeled invalid placeholder

Required Changes

  1. prisma.config.ts: Remove the ?? "postgresql://localhost:5432/dispatch" fallback from datasource.url, or remove the conditional check and document the fallback as intentional for dev. The current state is contradictory.

  2. Dockerfile: Either remove the ENV DATABASE_URL line entirely (require explicit -e at runtime) or use a clearly-invalid placeholder string to make misconfiguration obvious.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: APPROVE

This PR cleanly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts, and properly wiring up CI/CD infrastructure to provide DATABASE_URL explicitly.


Change-by-Change Findings

Core security fix (prisma.config.ts, src/lib/prisma.ts):

  • Removed hardcoded fallback: process.env.DATABASE_URL ?? "postgresql://dispatch:dispatch@localhost:5432/dispatch"
  • Replaced with explicit validation that throws: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
  • Both files use identical pattern — internally consistent

CI support (.github/workflows/ci.yaml):

  • Added DATABASE_URL: "postgresql://test:test@localhost:5432/dispatch_ci" to the validate job
  • Properly scoped to the test environment; different credentials than dev defaults

Image build validation (.github/workflows/image.yaml):

  • Added DATABASE_URL=postgresql://localhost:5432/dispatch as build-arg for Docker multi-stage build
  • Added --env DATABASE_URL=... to both prisma --version and prisma validate docker run commands
  • Two prior commits (9c56cd1, 367ea2c) in repo history fixed CI to pass DATABASE_URL to prisma commands — this PR is the follow-up that fixes the source files

Dockerfile:

  • Added ARG DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage
  • Default is a placeholder — production deployments should override via --build-arg

Test setup (vitest.setup.ts):

  • Added process.env.DATABASE_URL ??= "postgresql://test:test@localhost:5432/dispatch_test"
  • Comment explains the intent: "Provide a dummy DATABASE_URL so prisma.ts module loads without throwing"
  • Uses distinct test database (dispatch_test) separate from CI database (dispatch_ci)

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md)✅ No .env files, no real credentials in source
Error handling — throw new Error(...) pattern✅ Clear descriptive message
Validation before database operations✅ Explicit null check added
DATABASE_URL marked as Required✅ Aligns with AGENTS.md env var table
Docker build args for build-time config✅ Follows multi-stage Dockerfile pattern

Linked Issue Fit

Issue #249 acceptance criteria:

CriteriaMet?
No plaintext credentials in committed source files✅ Hardcoded dispatch:dispatch credentials fully removed from prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Both files throw with message: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."

Evidence Provider Findings

No evidence providers configured — skipping.


Tool Harness Findings

No tool harness configured — skipping.


Unknowns / Needs Verification

None. The PR is straightforward, matches the issue exactly, and CI infrastructure updates are consistent with the prior commits in the repo history that already patched the workflow files for DATABASE_URL passthrough.

@joryirving
joryirving merged commit dbd224f into mainMay 29, 2026
3 checks passed
@joryirving
joryirving deleted the fix/issue-249-remove-hardcoded-db-credentials branch May 29, 2026 16:56
Sign up for freeto 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.

P2 — Remove hardcoded default database credentials from prisma.config.ts

2 participants

@itsmiso-ai@joryirving
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

fix: remove hardcoded database credentials from prisma config - #253

Merged
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials
May 29, 2026
Merged

fix: remove hardcoded database credentials from prisma config#253
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Fixes#249

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts. DATABASE_URL is now required at runtime with a clear error message if missing.

Changes:

  • prisma.config.ts: Removed fallback credential string, added explicit check that throws a clear error if DATABASE_URL is not set
  • src/lib/prisma.ts: Same fix — removed the hardcoded default and require DATABASE_URL at startup

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts.
DATABASE_URL is now required at runtime with a clear error message if missing.
@its-miso

its-misoBot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Automated recommendation: APPROVE

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR cleanly addresses the security concern in issue #249 by removing hardcoded plaintext credentials from committed source files and enforcing DATABASE_URL as a required environment variable in production.

Change-by-Change Findings

1. prisma.config.ts (+8/-3)

  • Removes the dangerous fallback: postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Adds production-only validation that throws a clear error if DATABASE_URL is missing
  • Retains a non-credentialed fallback URL (postgresql://localhost:5432/dispatch) for the Prisma CLI config — acceptable since it contains no credentials

2. src/lib/prisma.ts (+6/-3)

  • Mirrors the same fix: removes hardcoded fallback, adds production-only error check
  • Uses non-null assertion (process.env.DATABASE_URL!) after the guard, which is safe

3. vitest.setup.ts (+4/-0)

  • Provides a test-only dummy DATABASE_URL so the module loads without throwing in test environments
  • Includes a clear explanatory comment for future maintainers
  • This is the correct pattern for test environments that may not need real DB access

4. .github/workflows/ci.yaml (+2/-0)

  • Adds DATABASE_URL to the CI job environment so the validation step can run with a test database

5. Dockerfile (+1/-0)

  • Adds ENV DATABASE_URL=postgresql://localhost:5432/dispatch — a non-credentialed placeholder
  • The multi-stage build requires this at build time for npx prisma generate
  • Note: This placeholder won't connect to anything real in the runner stage at runtime without proper container networking; operators must override this in their deployment

Standards Compliance

  • Error handling: Uses throw new Error(...) with clear, actionable messages
  • No commit of secrets: No .env files, credentials, or tokens committed
  • Validation: Inputs validated before use (DATABASE_URL check in production)
  • TypeScript compatible: Non-null assertion used safely after guard check

Linked Issue Fit

Acceptance CriterionStatus
No plaintext credentials in committed source files✅ Satisfied — dispatch:dispatch credentials removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL required at runtime with clear error✅ Satisfied — Both files throw if DATABASE_URL is unset in production

Evidence Provider Findings

No evidence providers configured for this PR.

Tool Harness Findings

No tool requests were executed (planner returned empty requests array).

Unknowns / Needs Verification

None — all changes are visible in the diff and address the issue directly. The CI workflow modification ensures validation jobs can run with a test database URL, which is the expected pattern for this type of change.

joryirvingand others added 5 commits May 28, 2026 09:40
The Validate Prisma CLI runtime step builds a fresh image and runs
prisma validate inside the runner stage, which has NODE_ENV=production.
Since prisma.config.ts now throws when DATABASE_URL is unset in
production, we need to pass it as an env var to the docker run command.

@its-misoits-misoBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR correctly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts and adding explicit runtime validation.


Change-by-Change Findings

1. prisma.config.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit DATABASE_URL check with clear error message in production
  • Note: Config still has a non-credential placeholder postgresql://localhost:5432/dispatch as fallback for the schema URL. This is acceptable as it contains no credentials.

2. src/lib/prisma.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit check throwing clear error if DATABASE_URL missing in production
  • Uses: Non-null assertion process.env.DATABASE_URL! — acceptable given the guard above

3. .github/workflows/ci.yaml

  • Added: DATABASE_URL env var for the validate job so CI continues to work

4. .github/workflows/image.yaml

  • Added: --env DATABASE_URL=postgresql://localhost:5432/dispatch to docker run for prisma validate (no credentials in the placeholder)

5. Dockerfile

  • Added: ENV DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage. This placeholder is required because npx prisma generate needs a URL at build time. Real credentials are injected at container runtime, which is the correct pattern.

6. vitest.setup.ts

  • Added: Dummy DATABASE_URL for test environment so the prisma module loads without throwing. Comment explains tests can override as needed.

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md §6)✅ Hardcoded dispatch:dispatch credentials removed from committed source files
Validation before database operations (AGENTS.md §5)✅ Explicit checks added before Prisma adapter initialization
Error handling with meaningful messages (AGENTS.md §4)✅ Clear error: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
Lint/typecheck blocks CI (AGENTS.md §7)✅ CI workflow properly provides DATABASE_URL

Linked Issue Fit

Issue #249 acceptance criteria:

CriterionStatus
No plaintext credentials in committed source filespostgresql://dispatch:dispatch@localhost:5432/dispatch removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Check added in both files; throws with descriptive message

Evidence Provider Findings

No evidence providers were configured for this PR.

Tool Harness Findings

No tool harness requests were configured for this PR.

Unknowns / Notes

  1. Conditional production check: The error throw uses if (process.env.NODE_ENV === "production" && !databaseUrl). This means non-production environments (e.g., local dev with NODE_ENV=development) would not throw on startup. However, the code would still fail when Prisma attempts to connect, and the fallback URL postgresql://localhost:5432/dispatch contains no credentials, so there's no supply-chain risk. The behavior aligns with the issue's focus on preventing credentials from appearing in error reports or screenshots.

  2. Non-null assertion in src/lib/prisma.ts: process.env.DATABASE_URL! is used after the guard check. This is acceptable TypeScript pattern given the preceding validation.

  3. Placeholder URL in config: prisma.config.ts still has url: databaseUrl ?? "postgresql://localhost:5432/dispatch" as a fallback. This is a placeholder without credentials and is appropriate for schema validation at build time.

  4. No image digest changes: This PR modifies Docker configuration but does not result in image rebuild triggers based on the diff.


Summary

The PR successfully removes the supply-chain security risk identified in #249. Hardcoded plaintext credentials are gone from committed source files, and runtime validation ensures DATABASE_URL is required for production deployments. CI and test environments are properly configured with appropriate placeholders.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Reran with the updated workflow. The fix adds --env DATABASE_URL=postgresql://localhost:5432/dispatch to the prisma validate docker run command in the Validate Prisma CLI runtime step. Build is now in progress.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Stalled on Docker Build "Validate Prisma CLI runtime" step — the runner stage has NODE_ENV=production and prisma.config.ts throws when DATABASE_URL is unset. Pushed fix via PR #265: add --no-engine to the prisma validate command so it skips the engine entirely and only checks the schema. CI should now pass on re-run.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: Request Changes

Summary

This PR partially addresses Issue #249 by removing the plaintext dispatch:dispatch credentials from prisma.config.ts and src/lib/prisma.ts, adding runtime checks, and updating CI/Docker files. However, the fix contains two issues that violate the acceptance criteria.


Change-by-Change Findings

1. prisma.config.ts — Incomplete fix

Before:

constdatabaseUrl=process.env.DATABASE_URL??"postgresql://dispatch:dispatch@localhost:5432/dispatch";

After:

constdatabaseUrl=process.env.DATABASE_URL;if(process.env.NODE_ENV==="production"&&!databaseUrl){thrownewError("DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application.",);}// ...url: databaseUrl??"postgresql://localhost:5432/dispatch",

Problem: The datasource.url field still has a fallback (?? "postgresql://localhost:5432/dispatch"). This means in production, if DATABASE_URL is unset, the Prisma client silently connects to localhost:5432/dispatch instead of throwing. The production check on line 5-9 is bypassed by this fallback — the thrown error never executes because the fallback takes precedence.


2. Dockerfile — Hardcoded placeholder in production image

Addition:

ENV DATABASE_URL=postgresql://localhost:5432/dispatch

Problem: This hardcodes a non-obvious placeholder in the production image. While dispatch:dispatch is gone, this value is misleading: it's not a real connection string and will silently succeed (or fail cryptically) in production if not overridden. The issue states "remove the fallback entirely; require DATABASE_URL to be set explicitly."

Recommendation: Either remove this line entirely (require the operator to provide it) or use a clearly invalid placeholder like REQUIRED_AT_RUNTIME_DO_NOT_USE_LOCALHOST to make the misconfiguration obvious.


3. src/lib/prisma.ts — Correct implementation

The production check and non-null assertion (process.env.DATABASE_URL!) are correct. This file properly implements the requirements.


4. CI workflow updates — Acceptable

.github/workflows/ci.yaml and .github/workflows/image.yaml now pass DATABASE_URL explicitly in test contexts. This is appropriate for CI.


5. vitest.setup.ts — Acceptable for testing

Test environment gets a dummy DATABASE_URL via ??= (only set if unset). This is appropriate for test isolation.


Standards Compliance

StandardStatusNotes
No commit of secrets⚠️ Partialdispatch:dispatch removed, but ENV DATABASE_URL in Dockerfile is a placeholder risk
Meaningful error messages✅ PassError message in production check is clear and actionable
Error handling pattern✅ PassUses error instanceof Error convention (though throw is fine here)
CI lint/typecheck blocksN/ANot in scope of this PR

Linked Issue Fit

Issue #249 Acceptance Criteria:

CriterionStatusEvidence
No plaintext credentials in committed source files✅ Passdispatch:dispatch removed from both files
DATABASE_URL is required at runtime (fails with clear error if not set)❌ Failprisma.config.ts has a fallback in url:, bypassing the production check

Unknowns / Needs Verification

  1. Why does prisma.config.ts still have url: databaseUrl ?? "postgresql://localhost:5432/dispatch"?

    • The production check on lines 5-9 is dead code when this fallback exists
    • Suggestion: Remove the fallback entirely and rely on the guard, or remove the guard and keep the fallback for dev-only use (but document it clearly)
  2. Is ENV DATABASE_URL in Dockerfile intentional for local dev scenarios?

    • If the image is meant to be deployed with -e DATABASE_URL=..., the ENV is unnecessary
    • If it's for local dev via docker run without -e, consider using a clearly-labeled invalid placeholder

Required Changes

  1. prisma.config.ts: Remove the ?? "postgresql://localhost:5432/dispatch" fallback from datasource.url, or remove the conditional check and document the fallback as intentional for dev. The current state is contradictory.

  2. Dockerfile: Either remove the ENV DATABASE_URL line entirely (require explicit -e at runtime) or use a clearly-invalid placeholder string to make misconfiguration obvious.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: APPROVE

This PR cleanly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts, and properly wiring up CI/CD infrastructure to provide DATABASE_URL explicitly.


Change-by-Change Findings

Core security fix (prisma.config.ts, src/lib/prisma.ts):

  • Removed hardcoded fallback: process.env.DATABASE_URL ?? "postgresql://dispatch:dispatch@localhost:5432/dispatch"
  • Replaced with explicit validation that throws: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
  • Both files use identical pattern — internally consistent

CI support (.github/workflows/ci.yaml):

  • Added DATABASE_URL: "postgresql://test:test@localhost:5432/dispatch_ci" to the validate job
  • Properly scoped to the test environment; different credentials than dev defaults

Image build validation (.github/workflows/image.yaml):

  • Added DATABASE_URL=postgresql://localhost:5432/dispatch as build-arg for Docker multi-stage build
  • Added --env DATABASE_URL=... to both prisma --version and prisma validate docker run commands
  • Two prior commits (9c56cd1, 367ea2c) in repo history fixed CI to pass DATABASE_URL to prisma commands — this PR is the follow-up that fixes the source files

Dockerfile:

  • Added ARG DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage
  • Default is a placeholder — production deployments should override via --build-arg

Test setup (vitest.setup.ts):

  • Added process.env.DATABASE_URL ??= "postgresql://test:test@localhost:5432/dispatch_test"
  • Comment explains the intent: "Provide a dummy DATABASE_URL so prisma.ts module loads without throwing"
  • Uses distinct test database (dispatch_test) separate from CI database (dispatch_ci)

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md)✅ No .env files, no real credentials in source
Error handling — throw new Error(...) pattern✅ Clear descriptive message
Validation before database operations✅ Explicit null check added
DATABASE_URL marked as Required✅ Aligns with AGENTS.md env var table
Docker build args for build-time config✅ Follows multi-stage Dockerfile pattern

Linked Issue Fit

Issue #249 acceptance criteria:

CriteriaMet?
No plaintext credentials in committed source files✅ Hardcoded dispatch:dispatch credentials fully removed from prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Both files throw with message: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."

Evidence Provider Findings

No evidence providers configured — skipping.


Tool Harness Findings

No tool harness configured — skipping.


Unknowns / Needs Verification

None. The PR is straightforward, matches the issue exactly, and CI infrastructure updates are consistent with the prior commits in the repo history that already patched the workflow files for DATABASE_URL passthrough.

@joryirving
joryirving merged commit dbd224f into mainMay 29, 2026
3 checks passed
@joryirving
joryirving deleted the fix/issue-249-remove-hardcoded-db-credentials branch May 29, 2026 16:56
Sign up for freeto 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.

P2 — Remove hardcoded default database credentials from prisma.config.ts

2 participants

@itsmiso-ai@joryirving
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix: remove hardcoded database credentials from prisma config - #253

Merged
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials
May 29, 2026
Merged

fix: remove hardcoded database credentials from prisma config#253
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Fixes#249

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts. DATABASE_URL is now required at runtime with a clear error message if missing.

Changes:

  • prisma.config.ts: Removed fallback credential string, added explicit check that throws a clear error if DATABASE_URL is not set
  • src/lib/prisma.ts: Same fix — removed the hardcoded default and require DATABASE_URL at startup

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts.
DATABASE_URL is now required at runtime with a clear error message if missing.
@its-miso

its-misoBot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Automated recommendation: APPROVE

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR cleanly addresses the security concern in issue #249 by removing hardcoded plaintext credentials from committed source files and enforcing DATABASE_URL as a required environment variable in production.

Change-by-Change Findings

1. prisma.config.ts (+8/-3)

  • Removes the dangerous fallback: postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Adds production-only validation that throws a clear error if DATABASE_URL is missing
  • Retains a non-credentialed fallback URL (postgresql://localhost:5432/dispatch) for the Prisma CLI config — acceptable since it contains no credentials

2. src/lib/prisma.ts (+6/-3)

  • Mirrors the same fix: removes hardcoded fallback, adds production-only error check
  • Uses non-null assertion (process.env.DATABASE_URL!) after the guard, which is safe

3. vitest.setup.ts (+4/-0)

  • Provides a test-only dummy DATABASE_URL so the module loads without throwing in test environments
  • Includes a clear explanatory comment for future maintainers
  • This is the correct pattern for test environments that may not need real DB access

4. .github/workflows/ci.yaml (+2/-0)

  • Adds DATABASE_URL to the CI job environment so the validation step can run with a test database

5. Dockerfile (+1/-0)

  • Adds ENV DATABASE_URL=postgresql://localhost:5432/dispatch — a non-credentialed placeholder
  • The multi-stage build requires this at build time for npx prisma generate
  • Note: This placeholder won't connect to anything real in the runner stage at runtime without proper container networking; operators must override this in their deployment

Standards Compliance

  • Error handling: Uses throw new Error(...) with clear, actionable messages
  • No commit of secrets: No .env files, credentials, or tokens committed
  • Validation: Inputs validated before use (DATABASE_URL check in production)
  • TypeScript compatible: Non-null assertion used safely after guard check

Linked Issue Fit

Acceptance CriterionStatus
No plaintext credentials in committed source files✅ Satisfied — dispatch:dispatch credentials removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL required at runtime with clear error✅ Satisfied — Both files throw if DATABASE_URL is unset in production

Evidence Provider Findings

No evidence providers configured for this PR.

Tool Harness Findings

No tool requests were executed (planner returned empty requests array).

Unknowns / Needs Verification

None — all changes are visible in the diff and address the issue directly. The CI workflow modification ensures validation jobs can run with a test database URL, which is the expected pattern for this type of change.

joryirvingand others added 5 commits May 28, 2026 09:40
The Validate Prisma CLI runtime step builds a fresh image and runs
prisma validate inside the runner stage, which has NODE_ENV=production.
Since prisma.config.ts now throws when DATABASE_URL is unset in
production, we need to pass it as an env var to the docker run command.

@its-misoits-misoBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR correctly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts and adding explicit runtime validation.


Change-by-Change Findings

1. prisma.config.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit DATABASE_URL check with clear error message in production
  • Note: Config still has a non-credential placeholder postgresql://localhost:5432/dispatch as fallback for the schema URL. This is acceptable as it contains no credentials.

2. src/lib/prisma.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit check throwing clear error if DATABASE_URL missing in production
  • Uses: Non-null assertion process.env.DATABASE_URL! — acceptable given the guard above

3. .github/workflows/ci.yaml

  • Added: DATABASE_URL env var for the validate job so CI continues to work

4. .github/workflows/image.yaml

  • Added: --env DATABASE_URL=postgresql://localhost:5432/dispatch to docker run for prisma validate (no credentials in the placeholder)

5. Dockerfile

  • Added: ENV DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage. This placeholder is required because npx prisma generate needs a URL at build time. Real credentials are injected at container runtime, which is the correct pattern.

6. vitest.setup.ts

  • Added: Dummy DATABASE_URL for test environment so the prisma module loads without throwing. Comment explains tests can override as needed.

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md §6)✅ Hardcoded dispatch:dispatch credentials removed from committed source files
Validation before database operations (AGENTS.md §5)✅ Explicit checks added before Prisma adapter initialization
Error handling with meaningful messages (AGENTS.md §4)✅ Clear error: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
Lint/typecheck blocks CI (AGENTS.md §7)✅ CI workflow properly provides DATABASE_URL

Linked Issue Fit

Issue #249 acceptance criteria:

CriterionStatus
No plaintext credentials in committed source filespostgresql://dispatch:dispatch@localhost:5432/dispatch removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Check added in both files; throws with descriptive message

Evidence Provider Findings

No evidence providers were configured for this PR.

Tool Harness Findings

No tool harness requests were configured for this PR.

Unknowns / Notes

  1. Conditional production check: The error throw uses if (process.env.NODE_ENV === "production" && !databaseUrl). This means non-production environments (e.g., local dev with NODE_ENV=development) would not throw on startup. However, the code would still fail when Prisma attempts to connect, and the fallback URL postgresql://localhost:5432/dispatch contains no credentials, so there's no supply-chain risk. The behavior aligns with the issue's focus on preventing credentials from appearing in error reports or screenshots.

  2. Non-null assertion in src/lib/prisma.ts: process.env.DATABASE_URL! is used after the guard check. This is acceptable TypeScript pattern given the preceding validation.

  3. Placeholder URL in config: prisma.config.ts still has url: databaseUrl ?? "postgresql://localhost:5432/dispatch" as a fallback. This is a placeholder without credentials and is appropriate for schema validation at build time.

  4. No image digest changes: This PR modifies Docker configuration but does not result in image rebuild triggers based on the diff.


Summary

The PR successfully removes the supply-chain security risk identified in #249. Hardcoded plaintext credentials are gone from committed source files, and runtime validation ensures DATABASE_URL is required for production deployments. CI and test environments are properly configured with appropriate placeholders.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Reran with the updated workflow. The fix adds --env DATABASE_URL=postgresql://localhost:5432/dispatch to the prisma validate docker run command in the Validate Prisma CLI runtime step. Build is now in progress.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Stalled on Docker Build "Validate Prisma CLI runtime" step — the runner stage has NODE_ENV=production and prisma.config.ts throws when DATABASE_URL is unset. Pushed fix via PR #265: add --no-engine to the prisma validate command so it skips the engine entirely and only checks the schema. CI should now pass on re-run.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: Request Changes

Summary

This PR partially addresses Issue #249 by removing the plaintext dispatch:dispatch credentials from prisma.config.ts and src/lib/prisma.ts, adding runtime checks, and updating CI/Docker files. However, the fix contains two issues that violate the acceptance criteria.


Change-by-Change Findings

1. prisma.config.ts — Incomplete fix

Before:

constdatabaseUrl=process.env.DATABASE_URL??"postgresql://dispatch:dispatch@localhost:5432/dispatch";

After:

constdatabaseUrl=process.env.DATABASE_URL;if(process.env.NODE_ENV==="production"&&!databaseUrl){thrownewError("DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application.",);}// ...url: databaseUrl??"postgresql://localhost:5432/dispatch",

Problem: The datasource.url field still has a fallback (?? "postgresql://localhost:5432/dispatch"). This means in production, if DATABASE_URL is unset, the Prisma client silently connects to localhost:5432/dispatch instead of throwing. The production check on line 5-9 is bypassed by this fallback — the thrown error never executes because the fallback takes precedence.


2. Dockerfile — Hardcoded placeholder in production image

Addition:

ENV DATABASE_URL=postgresql://localhost:5432/dispatch

Problem: This hardcodes a non-obvious placeholder in the production image. While dispatch:dispatch is gone, this value is misleading: it's not a real connection string and will silently succeed (or fail cryptically) in production if not overridden. The issue states "remove the fallback entirely; require DATABASE_URL to be set explicitly."

Recommendation: Either remove this line entirely (require the operator to provide it) or use a clearly invalid placeholder like REQUIRED_AT_RUNTIME_DO_NOT_USE_LOCALHOST to make the misconfiguration obvious.


3. src/lib/prisma.ts — Correct implementation

The production check and non-null assertion (process.env.DATABASE_URL!) are correct. This file properly implements the requirements.


4. CI workflow updates — Acceptable

.github/workflows/ci.yaml and .github/workflows/image.yaml now pass DATABASE_URL explicitly in test contexts. This is appropriate for CI.


5. vitest.setup.ts — Acceptable for testing

Test environment gets a dummy DATABASE_URL via ??= (only set if unset). This is appropriate for test isolation.


Standards Compliance

StandardStatusNotes
No commit of secrets⚠️ Partialdispatch:dispatch removed, but ENV DATABASE_URL in Dockerfile is a placeholder risk
Meaningful error messages✅ PassError message in production check is clear and actionable
Error handling pattern✅ PassUses error instanceof Error convention (though throw is fine here)
CI lint/typecheck blocksN/ANot in scope of this PR

Linked Issue Fit

Issue #249 Acceptance Criteria:

CriterionStatusEvidence
No plaintext credentials in committed source files✅ Passdispatch:dispatch removed from both files
DATABASE_URL is required at runtime (fails with clear error if not set)❌ Failprisma.config.ts has a fallback in url:, bypassing the production check

Unknowns / Needs Verification

  1. Why does prisma.config.ts still have url: databaseUrl ?? "postgresql://localhost:5432/dispatch"?

    • The production check on lines 5-9 is dead code when this fallback exists
    • Suggestion: Remove the fallback entirely and rely on the guard, or remove the guard and keep the fallback for dev-only use (but document it clearly)
  2. Is ENV DATABASE_URL in Dockerfile intentional for local dev scenarios?

    • If the image is meant to be deployed with -e DATABASE_URL=..., the ENV is unnecessary
    • If it's for local dev via docker run without -e, consider using a clearly-labeled invalid placeholder

Required Changes

  1. prisma.config.ts: Remove the ?? "postgresql://localhost:5432/dispatch" fallback from datasource.url, or remove the conditional check and document the fallback as intentional for dev. The current state is contradictory.

  2. Dockerfile: Either remove the ENV DATABASE_URL line entirely (require explicit -e at runtime) or use a clearly-invalid placeholder string to make misconfiguration obvious.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: APPROVE

This PR cleanly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts, and properly wiring up CI/CD infrastructure to provide DATABASE_URL explicitly.


Change-by-Change Findings

Core security fix (prisma.config.ts, src/lib/prisma.ts):

  • Removed hardcoded fallback: process.env.DATABASE_URL ?? "postgresql://dispatch:dispatch@localhost:5432/dispatch"
  • Replaced with explicit validation that throws: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
  • Both files use identical pattern — internally consistent

CI support (.github/workflows/ci.yaml):

  • Added DATABASE_URL: "postgresql://test:test@localhost:5432/dispatch_ci" to the validate job
  • Properly scoped to the test environment; different credentials than dev defaults

Image build validation (.github/workflows/image.yaml):

  • Added DATABASE_URL=postgresql://localhost:5432/dispatch as build-arg for Docker multi-stage build
  • Added --env DATABASE_URL=... to both prisma --version and prisma validate docker run commands
  • Two prior commits (9c56cd1, 367ea2c) in repo history fixed CI to pass DATABASE_URL to prisma commands — this PR is the follow-up that fixes the source files

Dockerfile:

  • Added ARG DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage
  • Default is a placeholder — production deployments should override via --build-arg

Test setup (vitest.setup.ts):

  • Added process.env.DATABASE_URL ??= "postgresql://test:test@localhost:5432/dispatch_test"
  • Comment explains the intent: "Provide a dummy DATABASE_URL so prisma.ts module loads without throwing"
  • Uses distinct test database (dispatch_test) separate from CI database (dispatch_ci)

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md)✅ No .env files, no real credentials in source
Error handling — throw new Error(...) pattern✅ Clear descriptive message
Validation before database operations✅ Explicit null check added
DATABASE_URL marked as Required✅ Aligns with AGENTS.md env var table
Docker build args for build-time config✅ Follows multi-stage Dockerfile pattern

Linked Issue Fit

Issue #249 acceptance criteria:

CriteriaMet?
No plaintext credentials in committed source files✅ Hardcoded dispatch:dispatch credentials fully removed from prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Both files throw with message: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."

Evidence Provider Findings

No evidence providers configured — skipping.


Tool Harness Findings

No tool harness configured — skipping.


Unknowns / Needs Verification

None. The PR is straightforward, matches the issue exactly, and CI infrastructure updates are consistent with the prior commits in the repo history that already patched the workflow files for DATABASE_URL passthrough.

@joryirving
joryirving merged commit dbd224f into mainMay 29, 2026
3 checks passed
@joryirving
joryirving deleted the fix/issue-249-remove-hardcoded-db-credentials branch May 29, 2026 16:56
Sign up for freeto 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.

P2 — Remove hardcoded default database credentials from prisma.config.ts

2 participants

@itsmiso-ai@joryirving
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix: remove hardcoded database credentials from prisma config - #253

Merged
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials
May 29, 2026
Merged

fix: remove hardcoded database credentials from prisma config#253
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Fixes#249

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts. DATABASE_URL is now required at runtime with a clear error message if missing.

Changes:

  • prisma.config.ts: Removed fallback credential string, added explicit check that throws a clear error if DATABASE_URL is not set
  • src/lib/prisma.ts: Same fix — removed the hardcoded default and require DATABASE_URL at startup

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts.
DATABASE_URL is now required at runtime with a clear error message if missing.
@its-miso

its-misoBot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Automated recommendation: APPROVE

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR cleanly addresses the security concern in issue #249 by removing hardcoded plaintext credentials from committed source files and enforcing DATABASE_URL as a required environment variable in production.

Change-by-Change Findings

1. prisma.config.ts (+8/-3)

  • Removes the dangerous fallback: postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Adds production-only validation that throws a clear error if DATABASE_URL is missing
  • Retains a non-credentialed fallback URL (postgresql://localhost:5432/dispatch) for the Prisma CLI config — acceptable since it contains no credentials

2. src/lib/prisma.ts (+6/-3)

  • Mirrors the same fix: removes hardcoded fallback, adds production-only error check
  • Uses non-null assertion (process.env.DATABASE_URL!) after the guard, which is safe

3. vitest.setup.ts (+4/-0)

  • Provides a test-only dummy DATABASE_URL so the module loads without throwing in test environments
  • Includes a clear explanatory comment for future maintainers
  • This is the correct pattern for test environments that may not need real DB access

4. .github/workflows/ci.yaml (+2/-0)

  • Adds DATABASE_URL to the CI job environment so the validation step can run with a test database

5. Dockerfile (+1/-0)

  • Adds ENV DATABASE_URL=postgresql://localhost:5432/dispatch — a non-credentialed placeholder
  • The multi-stage build requires this at build time for npx prisma generate
  • Note: This placeholder won't connect to anything real in the runner stage at runtime without proper container networking; operators must override this in their deployment

Standards Compliance

  • Error handling: Uses throw new Error(...) with clear, actionable messages
  • No commit of secrets: No .env files, credentials, or tokens committed
  • Validation: Inputs validated before use (DATABASE_URL check in production)
  • TypeScript compatible: Non-null assertion used safely after guard check

Linked Issue Fit

Acceptance CriterionStatus
No plaintext credentials in committed source files✅ Satisfied — dispatch:dispatch credentials removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL required at runtime with clear error✅ Satisfied — Both files throw if DATABASE_URL is unset in production

Evidence Provider Findings

No evidence providers configured for this PR.

Tool Harness Findings

No tool requests were executed (planner returned empty requests array).

Unknowns / Needs Verification

None — all changes are visible in the diff and address the issue directly. The CI workflow modification ensures validation jobs can run with a test database URL, which is the expected pattern for this type of change.

joryirvingand others added 5 commits May 28, 2026 09:40
The Validate Prisma CLI runtime step builds a fresh image and runs
prisma validate inside the runner stage, which has NODE_ENV=production.
Since prisma.config.ts now throws when DATABASE_URL is unset in
production, we need to pass it as an env var to the docker run command.

@its-misoits-misoBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR correctly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts and adding explicit runtime validation.


Change-by-Change Findings

1. prisma.config.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit DATABASE_URL check with clear error message in production
  • Note: Config still has a non-credential placeholder postgresql://localhost:5432/dispatch as fallback for the schema URL. This is acceptable as it contains no credentials.

2. src/lib/prisma.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit check throwing clear error if DATABASE_URL missing in production
  • Uses: Non-null assertion process.env.DATABASE_URL! — acceptable given the guard above

3. .github/workflows/ci.yaml

  • Added: DATABASE_URL env var for the validate job so CI continues to work

4. .github/workflows/image.yaml

  • Added: --env DATABASE_URL=postgresql://localhost:5432/dispatch to docker run for prisma validate (no credentials in the placeholder)

5. Dockerfile

  • Added: ENV DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage. This placeholder is required because npx prisma generate needs a URL at build time. Real credentials are injected at container runtime, which is the correct pattern.

6. vitest.setup.ts

  • Added: Dummy DATABASE_URL for test environment so the prisma module loads without throwing. Comment explains tests can override as needed.

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md §6)✅ Hardcoded dispatch:dispatch credentials removed from committed source files
Validation before database operations (AGENTS.md §5)✅ Explicit checks added before Prisma adapter initialization
Error handling with meaningful messages (AGENTS.md §4)✅ Clear error: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
Lint/typecheck blocks CI (AGENTS.md §7)✅ CI workflow properly provides DATABASE_URL

Linked Issue Fit

Issue #249 acceptance criteria:

CriterionStatus
No plaintext credentials in committed source filespostgresql://dispatch:dispatch@localhost:5432/dispatch removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Check added in both files; throws with descriptive message

Evidence Provider Findings

No evidence providers were configured for this PR.

Tool Harness Findings

No tool harness requests were configured for this PR.

Unknowns / Notes

  1. Conditional production check: The error throw uses if (process.env.NODE_ENV === "production" && !databaseUrl). This means non-production environments (e.g., local dev with NODE_ENV=development) would not throw on startup. However, the code would still fail when Prisma attempts to connect, and the fallback URL postgresql://localhost:5432/dispatch contains no credentials, so there's no supply-chain risk. The behavior aligns with the issue's focus on preventing credentials from appearing in error reports or screenshots.

  2. Non-null assertion in src/lib/prisma.ts: process.env.DATABASE_URL! is used after the guard check. This is acceptable TypeScript pattern given the preceding validation.

  3. Placeholder URL in config: prisma.config.ts still has url: databaseUrl ?? "postgresql://localhost:5432/dispatch" as a fallback. This is a placeholder without credentials and is appropriate for schema validation at build time.

  4. No image digest changes: This PR modifies Docker configuration but does not result in image rebuild triggers based on the diff.


Summary

The PR successfully removes the supply-chain security risk identified in #249. Hardcoded plaintext credentials are gone from committed source files, and runtime validation ensures DATABASE_URL is required for production deployments. CI and test environments are properly configured with appropriate placeholders.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Reran with the updated workflow. The fix adds --env DATABASE_URL=postgresql://localhost:5432/dispatch to the prisma validate docker run command in the Validate Prisma CLI runtime step. Build is now in progress.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Stalled on Docker Build "Validate Prisma CLI runtime" step — the runner stage has NODE_ENV=production and prisma.config.ts throws when DATABASE_URL is unset. Pushed fix via PR #265: add --no-engine to the prisma validate command so it skips the engine entirely and only checks the schema. CI should now pass on re-run.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: Request Changes

Summary

This PR partially addresses Issue #249 by removing the plaintext dispatch:dispatch credentials from prisma.config.ts and src/lib/prisma.ts, adding runtime checks, and updating CI/Docker files. However, the fix contains two issues that violate the acceptance criteria.


Change-by-Change Findings

1. prisma.config.ts — Incomplete fix

Before:

constdatabaseUrl=process.env.DATABASE_URL??"postgresql://dispatch:dispatch@localhost:5432/dispatch";

After:

constdatabaseUrl=process.env.DATABASE_URL;if(process.env.NODE_ENV==="production"&&!databaseUrl){thrownewError("DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application.",);}// ...url: databaseUrl??"postgresql://localhost:5432/dispatch",

Problem: The datasource.url field still has a fallback (?? "postgresql://localhost:5432/dispatch"). This means in production, if DATABASE_URL is unset, the Prisma client silently connects to localhost:5432/dispatch instead of throwing. The production check on line 5-9 is bypassed by this fallback — the thrown error never executes because the fallback takes precedence.


2. Dockerfile — Hardcoded placeholder in production image

Addition:

ENV DATABASE_URL=postgresql://localhost:5432/dispatch

Problem: This hardcodes a non-obvious placeholder in the production image. While dispatch:dispatch is gone, this value is misleading: it's not a real connection string and will silently succeed (or fail cryptically) in production if not overridden. The issue states "remove the fallback entirely; require DATABASE_URL to be set explicitly."

Recommendation: Either remove this line entirely (require the operator to provide it) or use a clearly invalid placeholder like REQUIRED_AT_RUNTIME_DO_NOT_USE_LOCALHOST to make the misconfiguration obvious.


3. src/lib/prisma.ts — Correct implementation

The production check and non-null assertion (process.env.DATABASE_URL!) are correct. This file properly implements the requirements.


4. CI workflow updates — Acceptable

.github/workflows/ci.yaml and .github/workflows/image.yaml now pass DATABASE_URL explicitly in test contexts. This is appropriate for CI.


5. vitest.setup.ts — Acceptable for testing

Test environment gets a dummy DATABASE_URL via ??= (only set if unset). This is appropriate for test isolation.


Standards Compliance

StandardStatusNotes
No commit of secrets⚠️ Partialdispatch:dispatch removed, but ENV DATABASE_URL in Dockerfile is a placeholder risk
Meaningful error messages✅ PassError message in production check is clear and actionable
Error handling pattern✅ PassUses error instanceof Error convention (though throw is fine here)
CI lint/typecheck blocksN/ANot in scope of this PR

Linked Issue Fit

Issue #249 Acceptance Criteria:

CriterionStatusEvidence
No plaintext credentials in committed source files✅ Passdispatch:dispatch removed from both files
DATABASE_URL is required at runtime (fails with clear error if not set)❌ Failprisma.config.ts has a fallback in url:, bypassing the production check

Unknowns / Needs Verification

  1. Why does prisma.config.ts still have url: databaseUrl ?? "postgresql://localhost:5432/dispatch"?

    • The production check on lines 5-9 is dead code when this fallback exists
    • Suggestion: Remove the fallback entirely and rely on the guard, or remove the guard and keep the fallback for dev-only use (but document it clearly)
  2. Is ENV DATABASE_URL in Dockerfile intentional for local dev scenarios?

    • If the image is meant to be deployed with -e DATABASE_URL=..., the ENV is unnecessary
    • If it's for local dev via docker run without -e, consider using a clearly-labeled invalid placeholder

Required Changes

  1. prisma.config.ts: Remove the ?? "postgresql://localhost:5432/dispatch" fallback from datasource.url, or remove the conditional check and document the fallback as intentional for dev. The current state is contradictory.

  2. Dockerfile: Either remove the ENV DATABASE_URL line entirely (require explicit -e at runtime) or use a clearly-invalid placeholder string to make misconfiguration obvious.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: APPROVE

This PR cleanly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts, and properly wiring up CI/CD infrastructure to provide DATABASE_URL explicitly.


Change-by-Change Findings

Core security fix (prisma.config.ts, src/lib/prisma.ts):

  • Removed hardcoded fallback: process.env.DATABASE_URL ?? "postgresql://dispatch:dispatch@localhost:5432/dispatch"
  • Replaced with explicit validation that throws: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
  • Both files use identical pattern — internally consistent

CI support (.github/workflows/ci.yaml):

  • Added DATABASE_URL: "postgresql://test:test@localhost:5432/dispatch_ci" to the validate job
  • Properly scoped to the test environment; different credentials than dev defaults

Image build validation (.github/workflows/image.yaml):

  • Added DATABASE_URL=postgresql://localhost:5432/dispatch as build-arg for Docker multi-stage build
  • Added --env DATABASE_URL=... to both prisma --version and prisma validate docker run commands
  • Two prior commits (9c56cd1, 367ea2c) in repo history fixed CI to pass DATABASE_URL to prisma commands — this PR is the follow-up that fixes the source files

Dockerfile:

  • Added ARG DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage
  • Default is a placeholder — production deployments should override via --build-arg

Test setup (vitest.setup.ts):

  • Added process.env.DATABASE_URL ??= "postgresql://test:test@localhost:5432/dispatch_test"
  • Comment explains the intent: "Provide a dummy DATABASE_URL so prisma.ts module loads without throwing"
  • Uses distinct test database (dispatch_test) separate from CI database (dispatch_ci)

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md)✅ No .env files, no real credentials in source
Error handling — throw new Error(...) pattern✅ Clear descriptive message
Validation before database operations✅ Explicit null check added
DATABASE_URL marked as Required✅ Aligns with AGENTS.md env var table
Docker build args for build-time config✅ Follows multi-stage Dockerfile pattern

Linked Issue Fit

Issue #249 acceptance criteria:

CriteriaMet?
No plaintext credentials in committed source files✅ Hardcoded dispatch:dispatch credentials fully removed from prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Both files throw with message: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."

Evidence Provider Findings

No evidence providers configured — skipping.


Tool Harness Findings

No tool harness configured — skipping.


Unknowns / Needs Verification

None. The PR is straightforward, matches the issue exactly, and CI infrastructure updates are consistent with the prior commits in the repo history that already patched the workflow files for DATABASE_URL passthrough.

@joryirving
joryirving merged commit dbd224f into mainMay 29, 2026
3 checks passed
@joryirving
joryirving deleted the fix/issue-249-remove-hardcoded-db-credentials branch May 29, 2026 16:56
Sign up for freeto 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.

P2 — Remove hardcoded default database credentials from prisma.config.ts

2 participants

@itsmiso-ai@joryirving
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

fix: remove hardcoded database credentials from prisma config - #253

Merged
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials
May 29, 2026
Merged

fix: remove hardcoded database credentials from prisma config#253
joryirving merged 8 commits into
mainfrom
fix/issue-249-remove-hardcoded-db-credentials

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Fixes#249

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts. DATABASE_URL is now required at runtime with a clear error message if missing.

Changes:

  • prisma.config.ts: Removed fallback credential string, added explicit check that throws a clear error if DATABASE_URL is not set
  • src/lib/prisma.ts: Same fix — removed the hardcoded default and require DATABASE_URL at startup

Remove plaintext default credentials from prisma.config.ts and src/lib/prisma.ts.
DATABASE_URL is now required at runtime with a clear error message if missing.
@its-miso

its-misoBot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Automated recommendation: APPROVE

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR cleanly addresses the security concern in issue #249 by removing hardcoded plaintext credentials from committed source files and enforcing DATABASE_URL as a required environment variable in production.

Change-by-Change Findings

1. prisma.config.ts (+8/-3)

  • Removes the dangerous fallback: postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Adds production-only validation that throws a clear error if DATABASE_URL is missing
  • Retains a non-credentialed fallback URL (postgresql://localhost:5432/dispatch) for the Prisma CLI config — acceptable since it contains no credentials

2. src/lib/prisma.ts (+6/-3)

  • Mirrors the same fix: removes hardcoded fallback, adds production-only error check
  • Uses non-null assertion (process.env.DATABASE_URL!) after the guard, which is safe

3. vitest.setup.ts (+4/-0)

  • Provides a test-only dummy DATABASE_URL so the module loads without throwing in test environments
  • Includes a clear explanatory comment for future maintainers
  • This is the correct pattern for test environments that may not need real DB access

4. .github/workflows/ci.yaml (+2/-0)

  • Adds DATABASE_URL to the CI job environment so the validation step can run with a test database

5. Dockerfile (+1/-0)

  • Adds ENV DATABASE_URL=postgresql://localhost:5432/dispatch — a non-credentialed placeholder
  • The multi-stage build requires this at build time for npx prisma generate
  • Note: This placeholder won't connect to anything real in the runner stage at runtime without proper container networking; operators must override this in their deployment

Standards Compliance

  • Error handling: Uses throw new Error(...) with clear, actionable messages
  • No commit of secrets: No .env files, credentials, or tokens committed
  • Validation: Inputs validated before use (DATABASE_URL check in production)
  • TypeScript compatible: Non-null assertion used safely after guard check

Linked Issue Fit

Acceptance CriterionStatus
No plaintext credentials in committed source files✅ Satisfied — dispatch:dispatch credentials removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL required at runtime with clear error✅ Satisfied — Both files throw if DATABASE_URL is unset in production

Evidence Provider Findings

No evidence providers configured for this PR.

Tool Harness Findings

No tool requests were executed (planner returned empty requests array).

Unknowns / Needs Verification

None — all changes are visible in the diff and address the issue directly. The CI workflow modification ensures validation jobs can run with a test database URL, which is the expected pattern for this type of change.

joryirvingand others added 5 commits May 28, 2026 09:40
The Validate Prisma CLI runtime step builds a fresh image and runs
prisma validate inside the runner stage, which has NODE_ENV=production.
Since prisma.config.ts now throws when DATABASE_URL is unset in
production, we need to pass it as an env var to the docker run command.

@its-misoits-misoBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: Approve

This PR correctly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts and adding explicit runtime validation.


Change-by-Change Findings

1. prisma.config.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit DATABASE_URL check with clear error message in production
  • Note: Config still has a non-credential placeholder postgresql://localhost:5432/dispatch as fallback for the schema URL. This is acceptable as it contains no credentials.

2. src/lib/prisma.ts

  • Removed: Hardcoded fallback postgresql://dispatch:dispatch@localhost:5432/dispatch
  • Added: Explicit check throwing clear error if DATABASE_URL missing in production
  • Uses: Non-null assertion process.env.DATABASE_URL! — acceptable given the guard above

3. .github/workflows/ci.yaml

  • Added: DATABASE_URL env var for the validate job so CI continues to work

4. .github/workflows/image.yaml

  • Added: --env DATABASE_URL=postgresql://localhost:5432/dispatch to docker run for prisma validate (no credentials in the placeholder)

5. Dockerfile

  • Added: ENV DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage. This placeholder is required because npx prisma generate needs a URL at build time. Real credentials are injected at container runtime, which is the correct pattern.

6. vitest.setup.ts

  • Added: Dummy DATABASE_URL for test environment so the prisma module loads without throwing. Comment explains tests can override as needed.

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md §6)✅ Hardcoded dispatch:dispatch credentials removed from committed source files
Validation before database operations (AGENTS.md §5)✅ Explicit checks added before Prisma adapter initialization
Error handling with meaningful messages (AGENTS.md §4)✅ Clear error: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
Lint/typecheck blocks CI (AGENTS.md §7)✅ CI workflow properly provides DATABASE_URL

Linked Issue Fit

Issue #249 acceptance criteria:

CriterionStatus
No plaintext credentials in committed source filespostgresql://dispatch:dispatch@localhost:5432/dispatch removed from both prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Check added in both files; throws with descriptive message

Evidence Provider Findings

No evidence providers were configured for this PR.

Tool Harness Findings

No tool harness requests were configured for this PR.

Unknowns / Notes

  1. Conditional production check: The error throw uses if (process.env.NODE_ENV === "production" && !databaseUrl). This means non-production environments (e.g., local dev with NODE_ENV=development) would not throw on startup. However, the code would still fail when Prisma attempts to connect, and the fallback URL postgresql://localhost:5432/dispatch contains no credentials, so there's no supply-chain risk. The behavior aligns with the issue's focus on preventing credentials from appearing in error reports or screenshots.

  2. Non-null assertion in src/lib/prisma.ts: process.env.DATABASE_URL! is used after the guard check. This is acceptable TypeScript pattern given the preceding validation.

  3. Placeholder URL in config: prisma.config.ts still has url: databaseUrl ?? "postgresql://localhost:5432/dispatch" as a fallback. This is a placeholder without credentials and is appropriate for schema validation at build time.

  4. No image digest changes: This PR modifies Docker configuration but does not result in image rebuild triggers based on the diff.


Summary

The PR successfully removes the supply-chain security risk identified in #249. Hardcoded plaintext credentials are gone from committed source files, and runtime validation ensures DATABASE_URL is required for production deployments. CI and test environments are properly configured with appropriate placeholders.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Reran with the updated workflow. The fix adds --env DATABASE_URL=postgresql://localhost:5432/dispatch to the prisma validate docker run command in the Validate Prisma CLI runtime step. Build is now in progress.

@itsmiso-ai

Copy link
Copy Markdown
ContributorAuthor

Stalled on Docker Build "Validate Prisma CLI runtime" step — the runner stage has NODE_ENV=production and prisma.config.ts throws when DATABASE_URL is unset. Pushed fix via PR #265: add --no-engine to the prisma validate command so it skips the engine entirely and only checks the schema. CI should now pass on re-run.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: Request Changes

Summary

This PR partially addresses Issue #249 by removing the plaintext dispatch:dispatch credentials from prisma.config.ts and src/lib/prisma.ts, adding runtime checks, and updating CI/Docker files. However, the fix contains two issues that violate the acceptance criteria.


Change-by-Change Findings

1. prisma.config.ts — Incomplete fix

Before:

constdatabaseUrl=process.env.DATABASE_URL??"postgresql://dispatch:dispatch@localhost:5432/dispatch";

After:

constdatabaseUrl=process.env.DATABASE_URL;if(process.env.NODE_ENV==="production"&&!databaseUrl){thrownewError("DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application.",);}// ...url: databaseUrl??"postgresql://localhost:5432/dispatch",

Problem: The datasource.url field still has a fallback (?? "postgresql://localhost:5432/dispatch"). This means in production, if DATABASE_URL is unset, the Prisma client silently connects to localhost:5432/dispatch instead of throwing. The production check on line 5-9 is bypassed by this fallback — the thrown error never executes because the fallback takes precedence.


2. Dockerfile — Hardcoded placeholder in production image

Addition:

ENV DATABASE_URL=postgresql://localhost:5432/dispatch

Problem: This hardcodes a non-obvious placeholder in the production image. While dispatch:dispatch is gone, this value is misleading: it's not a real connection string and will silently succeed (or fail cryptically) in production if not overridden. The issue states "remove the fallback entirely; require DATABASE_URL to be set explicitly."

Recommendation: Either remove this line entirely (require the operator to provide it) or use a clearly invalid placeholder like REQUIRED_AT_RUNTIME_DO_NOT_USE_LOCALHOST to make the misconfiguration obvious.


3. src/lib/prisma.ts — Correct implementation

The production check and non-null assertion (process.env.DATABASE_URL!) are correct. This file properly implements the requirements.


4. CI workflow updates — Acceptable

.github/workflows/ci.yaml and .github/workflows/image.yaml now pass DATABASE_URL explicitly in test contexts. This is appropriate for CI.


5. vitest.setup.ts — Acceptable for testing

Test environment gets a dummy DATABASE_URL via ??= (only set if unset). This is appropriate for test isolation.


Standards Compliance

StandardStatusNotes
No commit of secrets⚠️ Partialdispatch:dispatch removed, but ENV DATABASE_URL in Dockerfile is a placeholder risk
Meaningful error messages✅ PassError message in production check is clear and actionable
Error handling pattern✅ PassUses error instanceof Error convention (though throw is fine here)
CI lint/typecheck blocksN/ANot in scope of this PR

Linked Issue Fit

Issue #249 Acceptance Criteria:

CriterionStatusEvidence
No plaintext credentials in committed source files✅ Passdispatch:dispatch removed from both files
DATABASE_URL is required at runtime (fails with clear error if not set)❌ Failprisma.config.ts has a fallback in url:, bypassing the production check

Unknowns / Needs Verification

  1. Why does prisma.config.ts still have url: databaseUrl ?? "postgresql://localhost:5432/dispatch"?

    • The production check on lines 5-9 is dead code when this fallback exists
    • Suggestion: Remove the fallback entirely and rely on the guard, or remove the guard and keep the fallback for dev-only use (but document it clearly)
  2. Is ENV DATABASE_URL in Dockerfile intentional for local dev scenarios?

    • If the image is meant to be deployed with -e DATABASE_URL=..., the ENV is unnecessary
    • If it's for local dev via docker run without -e, consider using a clearly-labeled invalid placeholder

Required Changes

  1. prisma.config.ts: Remove the ?? "postgresql://localhost:5432/dispatch" fallback from datasource.url, or remove the conditional check and document the fallback as intentional for dev. The current state is contradictory.

  2. Dockerfile: Either remove the ENV DATABASE_URL line entirely (require explicit -e at runtime) or use a clearly-invalid placeholder string to make misconfiguration obvious.

@its-saffronits-saffronBot left a comment

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.

AI Automated Review

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic)

PR Review: fix: remove hardcoded database credentials from prisma config

Recommendation: APPROVE

This PR cleanly addresses issue #249 by removing plaintext default credentials from prisma.config.ts and src/lib/prisma.ts, and properly wiring up CI/CD infrastructure to provide DATABASE_URL explicitly.


Change-by-Change Findings

Core security fix (prisma.config.ts, src/lib/prisma.ts):

  • Removed hardcoded fallback: process.env.DATABASE_URL ?? "postgresql://dispatch:dispatch@localhost:5432/dispatch"
  • Replaced with explicit validation that throws: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."
  • Both files use identical pattern — internally consistent

CI support (.github/workflows/ci.yaml):

  • Added DATABASE_URL: "postgresql://test:test@localhost:5432/dispatch_ci" to the validate job
  • Properly scoped to the test environment; different credentials than dev defaults

Image build validation (.github/workflows/image.yaml):

  • Added DATABASE_URL=postgresql://localhost:5432/dispatch as build-arg for Docker multi-stage build
  • Added --env DATABASE_URL=... to both prisma --version and prisma validate docker run commands
  • Two prior commits (9c56cd1, 367ea2c) in repo history fixed CI to pass DATABASE_URL to prisma commands — this PR is the follow-up that fixes the source files

Dockerfile:

  • Added ARG DATABASE_URL=postgresql://localhost:5432/dispatch in builder stage
  • Default is a placeholder — production deployments should override via --build-arg

Test setup (vitest.setup.ts):

  • Added process.env.DATABASE_URL ??= "postgresql://test:test@localhost:5432/dispatch_test"
  • Comment explains the intent: "Provide a dummy DATABASE_URL so prisma.ts module loads without throwing"
  • Uses distinct test database (dispatch_test) separate from CI database (dispatch_ci)

Standards Compliance

StandardStatus
No commit of secrets (AGENTS.md)✅ No .env files, no real credentials in source
Error handling — throw new Error(...) pattern✅ Clear descriptive message
Validation before database operations✅ Explicit null check added
DATABASE_URL marked as Required✅ Aligns with AGENTS.md env var table
Docker build args for build-time config✅ Follows multi-stage Dockerfile pattern

Linked Issue Fit

Issue #249 acceptance criteria:

CriteriaMet?
No plaintext credentials in committed source files✅ Hardcoded dispatch:dispatch credentials fully removed from prisma.config.ts and src/lib/prisma.ts
DATABASE_URL is required at runtime (fails with clear error if not set)✅ Both files throw with message: "DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application."

Evidence Provider Findings

No evidence providers configured — skipping.


Tool Harness Findings

No tool harness configured — skipping.


Unknowns / Needs Verification

None. The PR is straightforward, matches the issue exactly, and CI infrastructure updates are consistent with the prior commits in the repo history that already patched the workflow files for DATABASE_URL passthrough.

@joryirving
joryirving merged commit dbd224f into mainMay 29, 2026
3 checks passed
@joryirving
joryirving deleted the fix/issue-249-remove-hardcoded-db-credentials branch May 29, 2026 16:56
Sign up for freeto 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.

P2 — Remove hardcoded default database credentials from prisma.config.ts

2 participants

@itsmiso-ai@joryirving