Skip to content

Reject deploy-key lines without an equals sign - #119

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog/auth-env-reject-missing-equals
Draft

posthog[bot] wants to merge 1 commit into
mainfrom
posthog/auth-env-reject-missing-equals

Conversation

@posthog

@posthog posthog Bot commented Oct 15, 2026

Copy link
Copy Markdown

Fixes PostHog Inbox report auth-env parser accepts lines without an equals sign.

Why: A malformed line in deploy-keys.env should stop scripts/auth-env.ts. Today the parser can instead turn it into a deploy key that looks valid.

Root cause

parseEnvFile called line.indexOf("=") and never checked for -1. With no =, line.slice(0, -1) drops the last character to make the key, and line.slice(0) makes the whole line the value. So CONVEX_PROD_DEPLOY_KEYX parsed as { CONVEX_PROD_DEPLOY_KEY: "CONVEX_PROD_DEPLOY_KEYX" } and passed the deploy-key presence check.

Change

  • A non-blank, non-comment line without = now throws Expected KEY=value on line N. The message leaves out the line's contents so a secret can't end up in the terminal.
  • Values that contain more = characters still parse as before; the existing dev:x=y test covers this.
  • Added a regression test in scripts/auth-env.test.ts.

Proof

Before the fix (new test only):

AssertionError: expected [Function] to throw an error
 ❯ scripts/auth-env.test.ts:153:61
 Tests  1 failed | 13 passed (14)

After the fix, bun run test -- run scripts/auth-env.test.ts:

 Test Files  1 passed (1)
      Tests  14 passed (14)

tsc -p tsconfig.node.json, eslint, and prettier --check on the changed files also pass.


Created with PostHog Desktop

🤖 Generated with Claude Code

parseEnvFile used indexOf("=") without checking for -1, so a malformed
line like CONVEX_PROD_DEPLOY_KEYX became the key CONVEX_PROD_DEPLOY_KEY
and passed the deploy-key presence check. Throw with the line number
instead, without echoing the line contents.

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

Generated-By: PostHog Desktop
Task-Id: 6e17da17-a2ab-4c0c-8076-becc8a5931c8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants