Skip to content

feat(issue): transition screen fields and validator attribution - #104

Merged
f3rdy merged 8 commits into
masterfrom
fix/issue-101-transition-screen-fields
Jul 31, 2026
Merged

f3rdy merged 8 commits into
masterfrom
fix/issue-101-transition-screen-fields

Conversation

@f3rdy

@f3rdy f3rdy commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Implements parts 2 and 3 of #101 plus --dry-run. Does not close the issue —
parts 1 (multi-hop path finding) and 4 (ADF) remain open, see below.

Spec: docs/superpowers/specs/2026-07-29-transition-screen-fields-design.md
Plan: docs/superpowers/plans/2026-07-29-transition-screen-fields.md

Problem

A transition whose screen carries a required field was un-completable from the
CLI
— not degraded, impossible. transition() passed no fields, and
get_transitions() never asked for screen metadata.

What changed

# Inspect what a transition needs, without touching the issue
budjira issue update PROJ-123 --status "Resolve" --dry-run

# Supply fields by id or by display name
budjira issue update PROJ-123 --status "Resolve" \
    --field resolution=Done \
    --field "Solution details=Rolled out"
  • budjira/models/transition.py — typed Transition / TransitionField.
  • TransitionService.get_transition_details() — requests expand=transitions.fields.
  • TransitionService.transition(fields=...) — forwards values.
  • budjira/utils/transition_fields.py — pure parse / resolve / encode / attribute
    helpers, no Jira client, so the fiddly logic is testable without mocks.
  • issue update — --field (repeatable), --dry-run, --interactive/--no-interactive.

Non-interactive callers (agents, CI, piped stdin) never get a prompt: a missing
required field aborts with the field ids, types and allowed values, ready to paste
back. Prompting is gated on a _can_prompt() TTY check, not just the flag, because
a forgotten --no-interactive would otherwise hang forever.

Two things worth a reviewer's attention

1. Validator attribution needed the __cause__ chain. The service layer converts
JIRAError into JiraAPIError and keeps only the error text, so the response body
with errorMessages survives nowhere else. Reading error.response directly would
have worked in unit tests and never in production. There is a test for the wrapped
shape specifically.

2. Matching is word-based, not substring. Jira rarely quotes the field name:
a field called Solution details is reported as "Provide details about the solution
made available."
Literal substring matching — what the spec originally described —
would never fire. Attribution now requires every significant word of the field name
to appear in the message, in any order, and returns nothing when two fields match
equally well, so Jira's own message is forwarded rather than the wrong field named.

Value encoding

--field resolution=Done would fail as a plain string. encode_field_value() wraps
per schema type: array → [{"value": v}], option → {"value": v},
resolution/priority → {"name": v}. Other structured types pass through
untouched and surface as a Jira error rather than being silently mangled.

Out of scope, deliberately

Incidental fixes

  • Transition models used positional Field(None, ...), which mypy does not treat as
    a default; switched to Field(default=None, ...).
  • .claude/ai-usage-prompt.md had been generated from a stale local
    ai-prompt-template.toml instead of the code defaults, so it was missing the
    --parent sub-task section and the sprint write-operations section. Regenerated
    from code. The documented regeneration command is machine-dependent — worth its
    own issue.
  • Two legacy call-shape assertions in test_jira_client.py now include fields=None,
    which is jira-python's own default, so fieldless transitions behave identically.

Tests

962 passed, 3 skipped. Coverage 86.90% overall;
transition_fields.py and models/transition.py at 100%, services/transitions.py
at 94%. Full pre-commit gate green.

f3rdy added 8 commits July 30, 2026 10:03
The two legacy call-shape assertions in test_jira_client now include
fields=None, which is jira-python's own default for that parameter, so the
behaviour of a fieldless transition is unchanged.
Jira rarely quotes the field name verbatim: a field called 'Solution details'
is reported as 'Provide details about the solution made available.' Literal
substring matching would therefore never fire in practice, so matching requires
every significant word of the field name to appear in the message, in any order.
Two equally good candidates yield no attribution, so the caller forwards Jira's
own message instead of naming the wrong field.
Prompting is gated on a _can_prompt() predicate rather than an inline
isatty() call: without a terminal a prompt would hang, which matters because
budjira is often driven by agents and CI where --no-interactive is forgotten.
Attribution walks the exception's __cause__ chain: the service layer converts
JIRAError into JiraAPIError and keeps only the error text, so the response body
with errorMessages survives nowhere else. Without the walk, attribution would
have fired in unit tests and never in production.

An unattributable validator message is forwarded with Jira's own wording plus
the transition's screen fields as context, instead of escaping as a traceback.

Also renames the changes-table loop variable, which shadowed the new --field
parameter.
Also fixes two things found while regenerating the AI prompt:

- The transition models used Field(None, ...) positionally, which mypy does not
  recognize as a default, so every construction that omitted an optional field
  failed --strict. Switched to Field(default=None, ...).
- .claude/ai-usage-prompt.md had been generated from a stale local
  ai-prompt-template.toml rather than from the code defaults, so it was missing
  the --parent sub-task section and the sprint write-operations section. It is
  now generated from the code defaults.
@f3rdy
f3rdy merged commit 50577e4 into master Jul 31, 2026
5 checks passed
@f3rdy
f3rdy deleted the fix/issue-101-transition-screen-fields branch July 31, 2026 04:48
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.

1 participant