fix(cli): prioritize LIGHTDASH_PROJECT over active previews - #28921
Merged
joaoviana merged 2 commits intoSep 11, 2026
Conversation
Contributor
|
🌈 The environment for this PR was shut down when it closed. Reopening the PR brings it back at the same URL. |
🧪 Test Selection✅ Tests that will run
⏭️ Tests skipped (no relevant file changes detected)
|
|
Your preview environment pr-28921 has been deployed. Preview environment endpoints are available at: |
Preview Environment🌐 URL: https://lightdash-preview-pr-28921.lightdash.okteto.dev 📋 Logs: View in GCP Console 🔧 SSH: |
Co-authored-by: joao@lightdash.com <joao@lightdash.com>
Share the override resolution between selectProject and rename so both paths apply --project > LIGHTDASH_PROJECT > active preview, and tell the user which preview was skipped when the environment variable wins. A preview that no longer exists is cleared from the config instead of being reported. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DhkPTUcayHNKi2jkr3bgKs
joaoviana
force-pushed
the
linear/prod-11044-ld-runner-prod-11044-3d80b4378ba7
branch
from
September 11, 2026 08:30
d9c0445 to
1fd75ab
Compare
joaoviana
marked this pull request as ready for review
September 11, 2026 08:35
joaoviana
deleted the
linear/prod-11044-ld-runner-prod-11044-3d80b4378ba7
branch
September 11, 2026 08:51
Collaborator
|
🎉 This PR is included in version 2.195.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Problem
LIGHTDASH_PROJECTis documented as "overrides the project UUID in the config file, useful when you want to target a specific project without using--project", but it only filled the production slot of the config. With a preview still recorded locally, non-interactive runs picked the preview anyway, so a CI deploy withLIGHTDASH_PROJECTset silently landed in a stale preview project for four days (customer report in PROD-11044).Fix
Project selection now resolves
--project>LIGHTDASH_PROJECT> active preview > saved project, in both interactive and non-interactive runs, through one helper (resolveProjectOverride) shared byselectProject(deploy, download, upload, slug-update, apps) and the rename command's separate path.When the environment variable overrides an active preview the CLI warns instead of switching silently:
The stored preview is validated before warning, so a preview that was already deleted is cleared from the config rather than reported. The saved preview is never cleared by the override itself;
stop-previewandset-projectkeep their meaning.getConfigalso stops returning the cached project name when the env var points at a different project, so logs no longer print a stale name next to the overridden UUID.Design discussion
The mental model raised in review ("once you start a preview, later commands target it until
set-projectorstop-preview") still holds for the config-file case: with no override set, an active preview is the non-interactive default and interactive runs prompt. The env var is treated as an explicit instruction, the same category as--project, because that is what the docs already promise and what every CI template relies on. The warning covers the local-dev case of aLIGHTDASH_PROJECTleft in a shell profile or.env.Regression analysis
cli-actionstemplates (deploy.yml,start-preview.yml,close-preview.yml,lightdash-validate.yml) all setLIGHTDASH_PROJECTto the production project.start-previewandstop-previewdo not go through project selection (they use the env project as the upstream to copy content from, and the preview by name), so preview workflows are unchanged.deployandvalidatealready targeted the env project on a fresh runner; on a runner with persisted CLI state they now do too, which is the fix.lightdash validatenever auto-selected a preview (only via--preview), so its behaviour is unchanged.--projectbehaviour is unchanged: no warning, no extra API call.--project,LIGHTDASH_PROJECTset, and a preview recorded in the local config. Previously: preview (non-interactive) or prompt (interactive). Now: env project plus a warning naming the ignored preview.GET /api/v1/projects/:uuidin that same case, to validate the preview before warning.Verification
pnpm -F cli test: 57 files, 706 tests pass, including new coverage for env-over-preview in both modes, the warning text, no warning without a preview or when the env var names the preview itself, deleted-preview cleanup, slug resolution from the env var,--projectprecedence, empty env var keeping the preview default, and rename targeting.pnpm -F cli typecheck,pnpm -F cli lint,oxfmtclean.main(2.194.1).Docs follow-up: lightdash/mintlify-docs#1243 updates the CLI reference and the preview guide.
Closes: PROD-11044
Closes #28836
🤖 Generated with Claude Code
https://claude.ai/code/session_01DhkPTUcayHNKi2jkr3bgKs