Add team states command; list valid states on wrong --state#247
Merged
Conversation
Discovering a team's valid workflow state names required a raw GraphQL query, and passing a wrong `--state` to `issue create`/`issue update` failed with a bare "Workflow state not found" and no hint at the valid options. Add `linear team states [teamKey]` (table + `--json`) reusing the existing getWorkflowStates helper, and make the wrong-state failure actionable: both issue commands now fetch the states once, resolve against them, and on a miss throw an error that lists the valid states and points at `linear team states`. Resolution moves to a pure resolveWorkflowState + a shared workflowStateNotFoundError factory so both call sites stay identical and the matching logic is unit-testable; the fetched list is reused for the suggestion (no second round-trip). The reporter also hypothesized a raw TypeError for unknown teams; verified this is false — team(id) is non-null in the schema and an unknown team already yields a clean "Could not find referenced Team." error, so no null guard is added. The `--state` help text was left unchanged to avoid churning the (width-sensitive, globally stale) generated skill docs; the enriched error is the load-bearing discovery path.
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
Adds
linear team states [teamKey]to list a team's workflow states, and makes a wrong--stateonissue create/issue updateactionable.Before, discovering valid state names meant a raw GraphQL query, and a wrong
--statefailed with a bareWorkflow state not found: 'X' for team XX— no hint at the options.Changes
linear team states [teamKey]— falls back to the configured team liketeam members; prints aNAME/TYPEtable sorted by position, or-j, --jsonas{ nodes: [...] }(GraphQL field names/connection shape preserved). Reuses the existinggetWorkflowStateshelper — no new GraphQL/codegen.Actionable wrong-state error —
issue create/issue updatenow fetch the states once, resolve against them, and on a miss throw an error whose suggestion lists the valid states and points atlinear team states <TEAM>:Resolution moves to a pure
resolveWorkflowStateplus a sharedworkflowStateNotFoundErrorfactory so both call sites stay identical and the matching logic is unit-tested; the fetched list is reused for the suggestion (no second round-trip).Deliberately out of scope
The issue also hypothesized a raw
TypeErrorfor unknown teams. I verified this is not the case —team(id)is non-null in the schema and an unknown team already yields a cleanCould not find referenced Team.— so no null guard was added. The--statehelp text was left unchanged to avoid churning the (width-sensitive, globally stale) generated skill docs; the enriched error is the load-bearing discovery path.Tests
Unit tests for
resolveWorkflowState(name/type precedence, duplicate-type ordering) andworkflowStateNotFoundError(formatting, quote escaping, empty-states); command snapshots (table sorting,--json, configured-team fallback, empty, no-team error) plus a registration guard; and end-to-end enriched-error snapshots for both issue commands.Fixes #210