Skip to content

fix(move): warn when Jira will discard --comment - #1024

Open
cstrahan wants to merge 1 commit into
ankitpokhrel:mainfrom
cstrahan:fix/move-comment-discard-warning
Open

cstrahan wants to merge 1 commit into
ankitpokhrel:mainfrom
cstrahan:fix/move-comment-discard-warning

Conversation

@cstrahan

@cstrahan cstrahan commented Sep 2, 2026

Copy link
Copy Markdown

What does this PR solve?

jira issue move --comment sends the comment inline in the transition request's update.comment block. Jira applies that only when the target transition has a screen containing the Comment field. Otherwise it performs the transition, returns 204, and silently discards the comment — the user sees ✓ Issue transitioned and the comment is simply gone.

The README already links Atlassian's KB article on configuring the workflow, but says only "if your workflow allows", without noting that the comment is lost when it doesn't.

I verified this against a live Jira Cloud workflow:

Transition Screen Result
Done 6 fields comment lands
every other transition in the workflow none HTTP 204, comment discarded

Tested four ways — a no-op self-transition, a genuine state-changing transition, a hand-built minimal payload, and JiraCLI's own payload. The outcome depends only on whether the transition has a screen, not on whether the status actually changes. This is not a payload bug in JiraCLI: the request it sends is correct and the comment lands wherever Jira accepts it.

The discard cannot be detected from the response, which is 204 with an empty body in both cases. It also cannot be read off the transition metadata directly, because Jira never lists comment in the transitions.fields expansion — not even for a transition that demonstrably accepts one. The one usable signal is whether the transition has a screen at all: an empty fields map means there is nowhere for the comment to go.

Changes:

  • Transition gains a Fields map, and the transitions lookup now requests expand=transitions.fields. This costs no extra request, because issue move already fetches the transition list to resolve the state name.
  • issue move warns before transitioning when --comment is set and the target transition has no screen, pointing the user at jira issue comment add. Behavior is otherwise unchanged — the comment is still sent inline, so workflows where it works keep the atomic single-request update.
  • The --comment flag help and the README now state the requirement and the failure mode.

A screen that exists but omits the Comment field still cannot be detected; that case is documented rather than warned about.

How to test?

On a workflow whose transitions have no screen (common for simple boards):

$ jira issue move ISSUE-1 "In Progress" --comment "this will be discarded"

Transition "In Progress" has no screen, so Jira will discard --comment.
Add it separately with: jira issue comment add ISSUE-1

✓ Issue transitioned to state "In Progress"

Before this change the same command printed only the success line and the comment vanished with no indication. Confirm with jira issue view ISSUE-1 --comments 5 that the comment is indeed absent — that is pre-existing Jira behavior, unchanged by this PR; only the warning is new.

On a transition that does have a screen (for example a Done transition with a resolution screen), no warning is printed and the comment is applied exactly as before.

go test ./pkg/jira/ -run TestTransitions covers the new field parsing and asserts that expand=transitions.fields is actually requested — without it, Fields is always empty and a screen-less transition becomes indistinguishable from one with a screen.

Checklist

  • I have added/updated enough tests related to my changes.
  • I have also manually checked and verified that my changes fix the issue and doesn't break any other functionalities.
  • My changes are backwards compatible.

`jira issue move --comment` sends the comment inline in the transition
request's `update.comment` block. Jira applies that only when the target
transition has a screen containing the Comment field. Otherwise it performs the
transition, returns 204, and silently discards the comment — the user sees
"✓ Issue transitioned" and the comment is simply gone.

Verified against Jira Cloud on a real workflow:

  transition with a screen (6 fields)  ->  comment lands
  transition with no screen            ->  HTTP 204, comment discarded

The discard cannot be detected from the response: the endpoint returns 204 with
an empty body either way. It also cannot be read directly off the transition
metadata, because Jira never lists `comment` in the `transitions.fields`
expansion — not even for a transition that does accept one. The one usable
signal is whether the transition has a screen at all; an empty `fields` map
means there is nowhere for the comment to go.

- `Transition` gains a `Fields` map and the transitions lookup now requests
  `expand=transitions.fields`. This adds no request: `issue move` already
  fetches the transition list to resolve the state name.

- `issue move` warns before transitioning when `--comment` is set and the
  target transition has no screen, pointing the user at `jira issue comment
  add`. Behavior is otherwise unchanged — the comment is still sent inline, so
  workflows where it works keep the atomic single-request update.

- The `--comment` flag help and the README now state the requirement and the
  silent-discard failure mode. The README already linked Atlassian's KB article
  on configuring the workflow, but said only "if your workflow allows", without
  noting that the comment is lost when it doesn't.

A screen that exists but omits the Comment field remains undetectable; that
case is documented rather than warned about.
Copilot AI lite review requested due to automatic review settings September 2, 2026 20:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is small, well-scoped, and includes tests validating the new transition expansion behavior without altering the underlying transition request semantics.

Pull request overview

This PR improves jira issue move --comment UX by warning users when Jira will accept the transition but silently discard the inline comment due to the target transition having no screen, and documents the limitation.

Changes:

  • Extend transition fetching to request expand=transitions.fields and parse the returned fields map to detect screen-less transitions.
  • Warn in jira issue move when --comment is used with a transition whose fields map is empty.
  • Document the failure mode in the README and expand the --comment flag help text.
File summaries
File Description
README.md Documents when Jira discards --comment and recommends jira issue comment add when unsure.
pkg/jira/types.go Adds Transition.Fields to capture transitions.fields expansion data.
pkg/jira/transition.go Requests expand=transitions.fields when listing transitions.
pkg/jira/transition_test.go Adds coverage for parsing fields and asserting the expand query is requested.
internal/cmd/issue/move/move.go Warns before transitioning when --comment is set and the chosen transition has no screen.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants