Environment-name to DOTENV_PRIVATE_KEY_* convention is not reversible (dotted vs underscored filenames collide)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- javascript
- Ambito
- cli
Direzione di ricerca
Inizia da src/lib/conventions/environment.js e src/lib/helpers/guessPrivateKeyFilename.js, quindi segui il loro utilizzo attraverso src/lib/helpers/envResolution/determine.js. Riproduci la collisione con .env.ci_test e .env.ci.test e aggiungi una copertura di regressione che dimostri che la ricerca implicita gestisce entrambe le forme valide del nome file senza selezionare il file errato né segnalare un file mancante.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
The convention that maps an env filename to its DOTENV_PRIVATE_KEY_* variable name (src/lib/conventions/environment.js) and the reverse mapping used for implicit file discovery (src/lib/helpers/guessPrivateKeyFilename.js) are not inverses of each other. Different, both-valid filenames collapse onto the same key name, so the reverse guess is ambiguous/wrong whenever an environment segment itself contains an underscore.
Where
environment.js joins multi-part (dot-separated) environment segments with _ when building the key suffix:
if (possibleEnvironmentList.length === 2) {
return possibleEnvironmentList.join('_')
}
guessPrivateKeyFilename.js always reverses an underscore back into a dot:
const filenameSuffix = privateKeyName.substring(`${PREFIX}_`.length).split('_').join('.').toLowerCase()
This is used by src/lib/helpers/envResolution/determine.js, which is the code path taken whenever a user relies on the documented implicit/zero-config convention (no -f flag, just DOTENV_PRIVATE_KEY_* set, e.g. in CI secrets).
Repro
const keynames = require('./src/lib/conventions/keynames')
keynames('.env.ci_test').privateKeyName // -> DOTENV_PRIVATE_KEY_CI_TEST
keynames('.env.ci.test').privateKeyName // -> DOTENV_PRIVATE_KEY_CI_TEST (same!)
Both .env.ci_test (single-word environment name, underscore) and .env.ci.test (two dot-separated segments) produce the identical key name DOTENV_PRIVATE_KEY_CI_TEST. But guessPrivateKeyFilename('DOTENV_PRIVATE_KEY_CI_TEST') always returns .env.ci.test.
So a project that names its file .env.ci_test and sets DOTENV_PRIVATE_KEY_CI_TEST (following dotenvx's own convention, no -f flag) will have dotenvx run go looking for .env.ci.test, a file that doesn't exist, and fail with a missing-env-file error, even though the correctly named file and matching key are both present.
Same collision applies more generally, e.g. .env.staging.local and .env.staging_local both map to DOTENV_PRIVATE_KEY_STAGING_LOCAL.
Suggested fix
Either disallow/escape underscores in environment segments when building the key name (so the mapping is bijective), or have determine() try both the dotted and underscored candidate filenames before giving up.
cc @motdotla, this affects the core zero-config file-discovery convention, so wanted to flag it directly.
- Lingua principale
- JavaScript
- Stelle
- 5.8k
- Fork
- 166
- Merge medio
- 4h 20m
- PR unite (30g)
- 35
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di dotenvx/dotenvx
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
dotenvx decrypt drops the backslash of \$, so a value with a literal $ changesForse già presa @owenshen0907 l’ha presa 10 giorni fa. Aperta
Difficoltà 3/5 Mezza giornata Idoneità per principianti 62/100
dotenvx/dotenvx#1016 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Using `decrypt`, existing shell env vars overwrite the encrypted onesForse già presa @jovial-liu l’ha presa 12 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
dotenvx/dotenvx#1005 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
dotenvx/dotenvx#995 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
dotenvx/dotenvx#700 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di dotenvx/dotenvx
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bluerobotics/Cockpit-docs#48 ·
-
README is out of date: broken badge, wrong command name, wrong Node version, placeholder URLsApertadocumentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
PhyberApex/slds-json-schema-renderer#372 ·
I maintainer di solito rispondono entro 1 giorno
-
usage: a custom provider's balance meters ("…%" in the balance path) ignore the Left/Used switchAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] rag: sentence content can cross the reported sentence boundariesForse già presa @LJK-ikun l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno