Repository navigation
fix(cli): note every project .env provider key before it is used - #8043
Closed
michaelwang11394 wants to merge 2 commits into
Closed
michaelwang11394 wants to merge 2 commits into
michaelwang11394 wants to merge 2 commits into
Conversation
…redential A project .env could set OPENROUTER_API_KEY, GEMINI_API_KEY, GOOGLE_API_KEY, the Vertex settings or ELEVENLABS_API_KEY and outrank a credential the person set in their shell or saved settings. The earlier rule covered only received projects; a cloned or downloaded project still won. Now every project .env provider key is unset, with a note naming the file, when a competing provider has a credential from a surer source: the shell or saved settings first, then the person's own project .env, then a received one. A project key with no competing credential is still used, model and timeout settings still apply, and the media-use scripts note an ElevenLabs key from any project .env before speech starts. In the CLI process an own-project key yields only within the vision choice; the media-use scripts remake the Gemini audio choice from the passed key origins.
A provider key from a project .env is still used when no own credential competes. Capture vision (OpenRouter, Gemini and the Vertex service account), snapshot --describe, Gemini speech and Lyria music now print one note per key before it is first used, naming the variable and the escaped .env path, as ElevenLabs already does. The ignoring notes escape the path too.
jrusso1020
previously approved these changes
Nov 17, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
Approving at 9cddadae (stacked on #8041; the merge order is yours).
- One shared helper.
noteProjectProviderKey(name, use)indotEnv.ts, and its media-use copy inheygen.mjs, notes once per key per process. It only notes whenprojectEnvDir(name)is set, meaning the liveprocess.envvalue is still the one the project.envsupplied. A key that has given way to yours (#8041) never notes.noteProjectElevenLabsKeyis now a wrapper, with the same wording as before. - The noted name matches the key actually read.
contentExtractorandsnapshot --describereadGEMINI_API_KEY || GOOGLE_API_KEY, andgeminiKeyName()picks the same one.gemini-auth.mjsdoes the same.- Lyria notes
GOOGLE_API_KEYfirst, matchinglyria-recipe.py. - OpenRouter and the Vertex service account are noted by their own names.
- Terminal safety. The
.envpath now goes throughterminalTextin both the new note and the existing "ignoring … from …" line, in both the CLI and media-use copies. The origin strings are fixed (receivedEnvOriginreturns one of three constants), so nothing else in the line comes from the project. - Tests. The body's "fails without the fix" line names the new cases: contentExtractor, snapshot contact sheet, dotEnv, bgm and gemini-auth.
Non-blocking:
heygen.mjsadds another hand copy ofterminalText. media-use already has the drift-testedterminal-text.mjsfrom #8013, so importing that would avoid a third copy.- Because this targets #8041's branch, only part of CI ran (7 pass, 1 pending). Full CI will run once it's retargeted to main.
— Rames
michaelwang11394
dismissed
jrusso1020’s stale review
November 17, 2026 07:58
The base branch was changed.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Contributor
Author
|
Replaced by #8056. #8041 merged in a narrower shape, so this change is rebuilt on main instead of on #8041's branch. The goal is the same: a one-line note whenever a provider key from a project |
3 of 4 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A provider key from a project
.envnow prints a one-line stderr note before it is first used. The note names the variable and the.envfile. This covers the providers #8041 leaves silent:OPENROUTER_API_KEY,GEMINI_API_KEY/GOOGLE_API_KEY, and the Vertex service accountHYPERFRAMES_VERTEX_SERVICE_ACCOUNT;snapshot --describe:GEMINI_API_KEY/GOOGLE_API_KEY;gemini-auth.mjs) and Lyria music (bgm.mjs):GEMINI_API_KEY/GOOGLE_API_KEY.The "ignoring" notes from #8041 now escape the path as well.
Why
#8041 makes a project
.envkey give way when the person has a competing credential of their own. When the person has no competing credential, the project key is still used. #8041 notes that case for ElevenLabs only. A project's OpenRouter, Gemini, Google or Vertex credential is still used silently, so images, frames, narration text or music prompts can go to the account behind someone else's key without the person knowing.Related work (follows #8004)
Follows #8004, and builds on #8041 (stacked on
fix-project-env-provider-keys). #8004 added the received-project rule and the ElevenLabs note. #8041 extends the rule to any project.envand notes ElevenLabs for any project key. This PR gives the remaining providers the same note. Merge #8041 first.How
packages/cli/src/utils/dotEnv.ts: the source lookup insideyieldProjectProviderKeysmoves to a module-levelprojectEnvSource(dir), so the newnoteProjectProviderKey(name, use)uses the same ranks and origin wording. The note prints only for a key set by a project.envthat survivedyieldProjectProviderKeys. It prints once per key per process, and it escapes the path withterminalText.contentExtractor.ts) notes the key the chosen provider reads. That isOPENROUTER_API_KEY, the Vertex service account, orGEMINI_API_KEYbeforeGOOGLE_API_KEY.snapshot --describenotes the Gemini key the same way.skills/media-use/audio/scripts/lib/heygen.mjs:noteProjectElevenLabsKeynow calls a sharednoteProjectProviderKey, and its wording does not change. A local copy of core'sterminalTextkeeps the skill standalone.geminiAuthcalls the shared note before Gemini speech. The Lyria branch ofgenerateBgmDetachedcalls it with the keylyria-recipe.pyreads first.Using <VAR> from <path>, <a project .env | a received project>: <what> goes to that key's <provider> account.docs/guides/authentication.mdxand the capture section ofdocs/packages/cli.mdxmention the note.No visible change
Nothing changes except a new stderr note when a provider key from a project
.envis used.Test plan
fails without the fix: each of these fails when the source change is reverted:
contentExtractor.test.ts: a received Gemini key, and a received Vertex service account, each caption with exactly one note;snapshot-contactSheet.test.ts:--describewith a project.envGemini key prints one note;gemini-auth.test.mjs: Gemini speech with a received key prints one note with the path escaped;bgm.test.mjs: Lyria music with a project key prints one note.dotEnv.test.tscovers an escaped path, the once-per-process rule, a key from the person's own project.env, and silence for a shell key. The tests that name folders with a control character skip that part on Windows, which refuses such names.vitest runondotEnv,contentExtractor,snapshot-contactSheet,cli.dotEnv,captureAttemptandmedia-usepasses (142 tests). All 259 media-use audio script tests pass.tsc --noEmitfor cli, oxlint, oxfmt, the comment ratchet andcheck-comment-citationspass.Unit tests added/updated
Manual testing performed
Documentation updated (if applicable)
Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug