Skip to content

✨Allow special keyword "null" in assign user#360

Open
fank wants to merge 2 commits intomainfrom
feature/issue-assign-null
Open

✨Allow special keyword "null" in assign user#360
fank wants to merge 2 commits intomainfrom
feature/issue-assign-null

Conversation

@fank
Copy link
Collaborator

@fank fank commented Apr 22, 2025

This pull request introduces a change to the assignIssue function in jira/internal/issue_impl.go to handle a special case for unassigning issues. The key update ensures that passing the string "null" as the accountID results in sending a JSON null value in the request payload, improving the clarity and functionality of the API.

Key change:

  • jira/internal/issue_impl.go: Updated the assignIssue function to handle the special case where "null" is passed as the accountID. This now sends a JSON null value in the payload to unassign the issue, with a note to allow passing a nil value in the next major version.

Fixes #355

@fank fank self-assigned this Apr 22, 2025
@fank fank requested a review from Copilot April 22, 2025 14:16
Copy link
Contributor

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 updates the assignIssue function to enable handling the special case where the accountID "null" triggers unassignment by sending a JSON null payload.

  • Introduces conditional payload formation based on the accountID value.
  • Includes a TODO note for future support of a direct nil value.

@fank fank added enhancement New feature or request Jira Software Cloud V2 Jira Cloud V2 V3 Jira Cloud V3 labels Apr 22, 2025
@fank fank changed the title Allow special keyword "null" in assign user ✨Allow special keyword "null" in assign user Apr 22, 2025
@fank fank requested a review from ctreminiom April 22, 2025 14:18
Comment on lines +150 to +153
if accountID == "null" {
// Special case: if "null" is passed, send a JSON null value to unassign the issue
// TODO: allow the user to pass a nil value in next major version
payload = map[string]interface{}{"accountId": nil}
Copy link
Collaborator Author

@fank fank Apr 22, 2025

Choose a reason for hiding this comment

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

Other possibility

Suggested change
if accountID == "null" {
// Special case: if "null" is passed, send a JSON null value to unassign the issue
// TODO: allow the user to pass a nil value in next major version
payload = map[string]interface{}{"accountId": nil}
if accountID == "" {
// Special case: if an empty string is passed, send a JSON null value to unassign the issue
// TODO: allow the user to pass a nil value in next major version
payload = map[string]interface{}{"accountId": nil}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@oogali what do you think?

Copy link

Choose a reason for hiding this comment

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

@fank I think if there's a special value it can be null as you've suggested, or something more explicit and context-specific along the lines of unassigned.

I'm also okay with an empty string, however I think that would need a bit stronger, clearer language in the documentation to reflect that behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change enhancement New feature or request Jira Software Cloud V2 Jira Cloud V2 V3 Jira Cloud V3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot unassign issues

3 participants