Skip to content

issue_994: Add optional role/group comment visibility via REST v3 and CLI flags#995

Open
jordanlgraham wants to merge 1 commit into
ankitpokhrel:mainfrom
jordanlgraham:issue_994
Open

issue_994: Add optional role/group comment visibility via REST v3 and CLI flags#995
jordanlgraham wants to merge 1 commit into
ankitpokhrel:mainfrom
jordanlgraham:issue_994

Conversation

@jordanlgraham
Copy link
Copy Markdown

Summary

Adds optional --visibility-role and --visibility-group flags to jira issue comment add. When either is set, the client uses Jira REST v3 POST /rest/api/3/issue/{issueIdOrKey}/comment with a visibility object (type + value only) and a valid v3 comment body.

When neither flag is set, behavior is unchanged (existing v2 flow, markdown handling, --internal / sd.public.comment unchanged).

Fixes #994.

Behavior

Case Behavior
No visibility flags Same as today (REST v2, existing comment body handling).
--visibility-role <name> v3 endpoint; visibility: { "type": "role", "value": "<name>" }.
--visibility-group <name> v3 endpoint; visibility: { "type": "group", "value": "<name>" }.
  • --visibility-role and --visibility-group are mutually exclusive with each other.
  • --internal is mutually exclusive with --visibility-role / --visibility-group (calling them together exits with a clear error; avoids ambiguous precedence).

Notes

  • Jira Cloud identifier and value are mutually exclusive in visibility; this PR uses only type + value for role/group visibility (matches Cloud behavior and avoids HTTP 400 from sending both).

Testing

  • Manual: add comment without flags → unchanged.
  • Manual: --visibility-role / --visibility-group → comment restricted as expected on Jira Cloud.
  • Error paths: conflicting flags rejected with readable message.

Refs: Add comment (v3)

Copilot AI review requested due to automatic review settings May 7, 2026 19:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds optional role/group-based visibility restrictions to jira issue comment add by introducing new CLI flags and routing restricted comments through Jira’s REST API v3 comment endpoint with an ADF body, while keeping the existing REST v2 + markdown→wiki behavior unchanged when no visibility flags are used.

Changes:

  • Add --visibility-role / --visibility-group flags to jira issue comment add and pass them through to the Jira client.
  • Introduce IssueCommentOptions and a new AddIssueCommentOpts code path that posts comments via REST v3 with visibility when role/group visibility is requested.
  • Document the new flags and clarify v3 ADF body behavior in the README.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
README.md Documents the new visibility flags and notes the v3 ADF/plain-text behavior.
pkg/jira/issue.go Adds options/validation, ADF conversion helper, and v3 posting path for visibility-restricted comments.
pkg/jira/issue_test.go Adds tests for options validation and verifies v3 request payload/path for role/group visibility.
internal/cmd/issue/comment/add/add.go Adds new CLI flags and wires them into the Jira client call.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/jira/issue.go
Comment on lines +372 to +373
block = strings.TrimSpace(block)
if block == "" {
Comment thread pkg/jira/issue.go
Comment on lines +355 to +360
// commentPlainToADF builds a minimal Atlassian Document body from plain text (paragraphs split on
// blank lines; single newlines become hard breaks). Used for REST v3 comments when setting visibility.
func commentPlainToADF(text string) *adf.ADF {
text = strings.ReplaceAll(text, "\r\n", "\n")
text = strings.TrimRight(text, "\n")
if text == "" {
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.

Feature request: optional project-role / group visibility on jira issue comment add (REST v3)

2 participants