Skip to content

Add team states command; list valid states on wrong --state#247

Merged
schpetbot merged 1 commit into
mainfrom
schpet/push-zpvxzoqlsmvk
Jul 17, 2026
Merged

Add team states command; list valid states on wrong --state#247
schpetbot merged 1 commit into
mainfrom
schpet/push-zpvxzoqlsmvk

Conversation

@schpetbot

Copy link
Copy Markdown
Collaborator

What

Adds linear team states [teamKey] to list a team's workflow states, and makes a wrong --state on issue create/issue update actionable.

Before, discovering valid state names meant a raw GraphQL query, and a wrong --state failed with a bare Workflow state not found: 'X' for team XX — no hint at the options.

Changes

  • linear team states [teamKey] — falls back to the configured team like team members; prints a NAME/TYPE table sorted by position, or -j, --json as { nodes: [...] } (GraphQL field names/connection shape preserved). Reuses the existing getWorkflowStates helper — no new GraphQL/codegen.

  • Actionable wrong-state errorissue create/issue update now fetch the states once, resolve against them, and on a miss throw an error whose suggestion lists the valid states and points at linear team states <TEAM>:

    ✗ Failed to update issue: Workflow state not found: 'notarealstate' for team CLI
      Valid states: "Backlog" (backlog), "Todo" (unstarted), … Run `linear team states CLI` to list them.
    

    Resolution moves to a pure resolveWorkflowState plus a shared workflowStateNotFoundError factory 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 TypeError for unknown teams. I verified this is not the case — team(id) is non-null in the schema and an unknown team already yields a clean Could not find referenced Team. — so no null guard was 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.

Tests

Unit tests for resolveWorkflowState (name/type precedence, duplicate-type ordering) and workflowStateNotFoundError (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

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.
@schpetbot
schpetbot merged commit b3a41f7 into main Jul 17, 2026
15 checks passed
@schpetbot
schpetbot deleted the schpet/push-zpvxzoqlsmvk branch July 17, 2026 21:06
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.

Add command to list workflow states for a team

2 participants