Skip to content

fix(lk): --dev with an API key or secret is an error - #1084

Merged
Topherhindman merged 2 commits into
mainfrom
topherhindman/lk-dev-with-api-key-is-an-error
Oct 27, 2026
Merged

Topherhindman merged 2 commits into
mainfrom
topherhindman/lk-dev-with-api-key-is-an-error

Conversation

@Topherhindman

Copy link
Copy Markdown
Contributor

--api-key and --api-secret also read LIVEKIT_API_KEY and LIVEKIT_API_SECRET. So lk --dev room list in a shell with those set made project resolution fail with "both api-key and dev flags are set". Commands that pick a project (room, sip, number, token create, app, cloud agents) treated that failure like nothing resolving and fell back to project selection. Non-interactive with one configured project, lk quietly acted on that cloud project instead of the local dev server. In a terminal you got the project picker instead.

This makes the conflict an error everywhere, in the same way #1076 did for a --project or --subdomain that doesn't resolve. The message names what to remove:

$ LIVEKIT_API_KEY=APIenv lk --dev room list
--dev can't be combined with API key credentials; unset LIVEKIT_API_KEY or drop --dev

It says "remove --api-key" when the value came from the flag. Commands that already failed here (egress, ingress, dispatch) now get the same message. --dev alone, or with --url, is unchanged.

Tests:

  • A unit test for the message and for requireProjectWithOpts not falling back.
  • A script test (dev-with-api-key.txtar): env key, env key and secret, and the flag all fail with no request to the configured project, and --dev alone still uses the dev credentials.
  • The credential property test now requires --dev with an inline key or secret to fail in API-key mode, instead of letting room list fall back.

--api-key and --api-secret also read LIVEKIT_API_KEY and
LIVEKIT_API_SECRET, so --dev in a shell with those set made
resolveProject fail with "both api-key and dev flags are set".
requireProjectWithOpts treated that like nothing resolving and fell
back to selectProject, which in non-interactive mode quietly used the
only configured project: lk acted on a cloud project instead of the
local dev server. It now returns the error, as it does for a --project
or --subdomain that doesn't resolve.

The error names what to remove: the env var when the value is the env
var's, the flag otherwise, e.g. "--dev can't be combined with API key
credentials; unset LIVEKIT_API_KEY or drop --dev". Commands using
loadProjectDetails already failed here, and now get the same message.
--dev alone, or with --url, is unchanged.
In API-key mode, --dev with an API key or secret from a flag or the
environment is now an error for every command, so the property requires
lk to fail without naming a project, instead of letting room list fall
back to the only configured project.
@Topherhindman
Topherhindman merged commit fdd1587 into main Oct 27, 2026
26 checks passed
@Topherhindman
Topherhindman deleted the topherhindman/lk-dev-with-api-key-is-an-error branch October 27, 2026 22:03
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.

2 participants