fix: pass teamId when resolving state and labels in update/list commands#1
Open
Natsukingdom wants to merge 1 commit intorolaca11:mainfrom
Open
fix: pass teamId when resolving state and labels in update/list commands#1Natsukingdom wants to merge 1 commit intorolaca11:mainfrom
Natsukingdom wants to merge 1 commit intorolaca11:mainfrom
Conversation
In the `update` command's flag-processing branch, `resolveStateId()` and `resolveLabelIds()` were called without passing `teamId`. In workspaces with multiple teams that have identically-named workflow states (e.g. "Todo", "In Progress", "Done"), this caused the resolver to pick the first matching state from any team, which could belong to a different team than the issue being updated. The Linear API then rejects the update with: "Discrepancy between issue team and state, cycle or project". The fix fetches the issue's team ID before resolving state/labels and passes it to both `resolveStateId()` and `resolveLabelIds()`, matching the pattern already used in the `create` command. Additionally, the `list` command had the same issue: the `teamId` variable was scoped inside the `if (teamFilter)` block and not available when resolving the `--state` filter. This is fixed by hoisting the variable so it can be reused. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
issues updatecommand: pass the issue'steamIdtoresolveStateId()andresolveLabelIds()in the flag-processing (non-interactive) branchissues listcommand: hoist theteamIdvariable so it can be passed toresolveStateId()when filtering by--stateProblem
In workspaces with multiple teams, the
updateandlistcommands resolve workflow state names (e.g. "Todo", "In Progress", "Done") without team context. Since every team typically has states with the same names,resolveStateId()picks the first match from any team, which may not be the correct one.For
issues update, this causes the Linear API to reject the update with:For
issues list, filtering by--statecombined with--teamcould silently use a state ID from the wrong team, returning incorrect results.Root Cause
updatecommand (flag-processing branch):resolveStateId(options.state)andresolveLabelIds(labelNames)were called withoutteamId, even though theresolveStateId()andresolveLabelIds()functions already accept an optionalteamIdparameter and thecreatecommand correctly passes it.listcommand: TheteamIdvariable was declared inside theif (teamFilter)block scope and was not accessible when resolving the--statefilter.Fix
update: Before resolving state/labels, fetch the issue's team ID viaclient.issue(issueId)and pass it to bothresolveStateId()andresolveLabelIds(). The extra API call is only made when--stateor--labelsflags are provided.list: Hoist theteamIdvariable (resolvedTeamId) outside theif (teamFilter)block so it can be passed toresolveStateId().This aligns the
updateandlistcommands with the pattern already used in thecreatecommand (line 238 and 251 in the original code).Test plan
linear issues update ISSUE-ID --state "Done"works correctly in a multi-team workspacelinear issues list --team TEAM --state "Todo"returns correct results filtered to the specified team's "Todo" statenpm run buildcompiles without errors🤖 Generated with Claude Code