fix(workspace): honor explicit --workspace-id before requiring current workspace context#2182
Open
jlaneve wants to merge 1 commit into
Open
fix(workspace): honor explicit --workspace-id before requiring current workspace context#2182jlaneve wants to merge 1 commit into
jlaneve wants to merge 1 commit into
Conversation
…t workspace context coalesceWorkspace() called workspace.GetCurrentWorkspace() first and returned its error before ever consulting the --workspace-id flag. With an org-scoped (workspace-operator) API token in a fresh CI home, the current-workspace context is empty (the token has no workspaceId claim), so the command failed with "current workspace context not set" even when --workspace-id was explicitly supplied. Return an explicit --workspace-id before calling GetCurrentWorkspace so the flag is authoritative in non-interactive flows. This covers every command routed through coalesceWorkspace (deployment variable update, deployment objects, worker queues, deploy, dbt, env, inspect). Adds TestCoalesceWorkspace covering: explicit flag with no current context (the regression), flag precedence over context, context fallback, and the no-source error. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Coverage Report for CI Build 27781374546Coverage increased (+0.007%) to 45.098%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
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
When authenticating non-interactively with an organization-scoped (workspace-operator) API token via
ASTRO_API_TOKEN, commands likeastro deployment variable updatefail with:Passing
--workspace-id <id>does not prevent the error — the flag is silently ignored on this path.Root cause
coalesceWorkspace()calledworkspace.GetCurrentWorkspace()first and returned its error before ever consulting the--workspace-idflag:An org-scoped token has no
workspaceIdclaim, so in a fresh CI homecheckAPITokenleavesc.Workspaceempty.GetCurrentWorkspace()then errors, and because the flag is checked after,--workspace-idcannot rescue it. This is deterministic given an empty current-workspace context (it only looks intermittent because a priorastro workspace switchmay have persisted a workspace).Fix
Return an explicit
--workspace-idbefore callingGetCurrentWorkspace(), making the flag authoritative in non-interactive flows. This covers every command routed throughcoalesceWorkspace(deployment variable update, deployment objects, worker queues, deploy, dbt, env, inspect) — not justvariable update.Tests
Adds
TestCoalesceWorkspacecovering:Workaround (pre-fix)
astro workspace switch <id>first persistsc.Workspace, after which the command succeeds. Confirmed still valid on affected versions.🤖 Generated with Claude Code