Skip to content

Refuse to start when config.json, .env, or .env.local sets a key twice - #2609

Open
kmcginnes wants to merge 1 commit into
t3/typescript-startup-stack-4-env-https-settingfrom
t3/typescript-startup-stack-5-duplicate-keys
Open

kmcginnes wants to merge 1 commit into
t3/typescript-startup-stack-4-env-https-settingfrom
t3/typescript-startup-stack-5-duplicate-keys

Conversation

@kmcginnes

@kmcginnes kmcginnes commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

When a key appears on more than one line, only one line takes effect, and which one depends on the file, so startup now stops and names the file, the key, and its lines.

/config/.env sets LOG_LEVEL more than once, on lines 1 and 2. Keep one line for each key and remove the others. Earlier versions used the last line.

This covers config.json, .env, and .env.local, and the export, colon, CRLF, and CR forms dotenv reads. The lines earlier versions appended to .env don't count.

Upgrade notes

  • A key set more than once in config.json, .env, or .env.local now stops startup with an error that names the file, the key, and its lines, so keep one line for each key and remove the others. In .env and .env.local, earlier versions used the last line, so keep that one to start as before.

Evidence

After: new tests refuse each duplicate form with its line numbers, and an operator's line above an appended block starts normally.

Verified live: on Colima, .env and .env.local duplicates in each form stop startup with the message above, and a config.json duplicate stops with its own wording.

Merge Danger

Door: two-way

Impact: breakage for deployments with a key repeated in one file.

Related


🤖 Written by an AI agent on my behalf.

@kmcginnes
kmcginnes added this pull request to stack #2613 November 13, 2026 23:39

This branch has not been deployed

No deployments
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.

1 participant