Skip to content

feat: add support for user-type custom fields#944

Open
alastori wants to merge 1 commit intoankitpokhrel:mainfrom
alastori:feat/user-custom-field-support
Open

feat: add support for user-type custom fields#944
alastori wants to merge 1 commit intoankitpokhrel:mainfrom
alastori:feat/user-custom-field-support

Conversation

@alastori
Copy link
Copy Markdown

@alastori alastori commented Feb 9, 2026

Adds handling for user-type custom fields in both create and edit paths.

Problem

User-type custom fields passed via --custom are silently dropped. The CLI reports "Issue updated" but the field remains null. This happens because the custom field switch statement only handles option, array, number, project, and the default (string) cases — but Jira's REST API requires user fields to be objects ({"accountId":"..."} for Cloud, {"name":"..."} for Server/DC), not plain strings.

Solution

  • Add customFieldTypeUser and customFieldTypeUserSet types following the existing pattern
  • Add newCustomFieldTypeUser() constructor that branches on Cloud vs Local installation
  • Handle user schema type for single-user fields in both constructCustomFields (create) and constructCustomFieldsForEdit (edit)
  • Handle user items type for multi-user picker arrays in both paths
  • Pass installationType through to constructCustomFields in the create path (edit already had it)
  • Convert if/else chains to switch in the array sub-cases (gocritic lint)

How to test?

Unit tests (18 new tests):

go test -race ./pkg/jira/... -run "Custom|Edit|User" -v

Manual verification:

  1. Create a free Jira Cloud instance at atlassian.com
  2. Add a "User Picker (single user)" custom field (e.g., "PM owner")
  3. Run jira init and map the field in config under issue.fields.custom with datatype: user
  4. Create or edit an issue: jira issue edit TEST-1 --custom "pm-owner=<accountId>" --no-input
  5. Verify the field is set via the Jira UI or REST API

Tested end-to-end on a real Jira Cloud instance.

Checklist

  • Tests added
  • Manual verification done
  • Backwards compatible (all changed functions are unexported)
  • Lint clean (golangci-lint 0 issues)

Fixes #798, #758, #579

Add handling for user-type custom fields in both create and edit paths.
Previously, user-type fields passed via --custom were silently dropped
because the code only handled option, array, number, project, and
string types. User fields require {"accountId":"..."} for Cloud or
{"name":"..."} for Server/DC installations.

Changes:
- Add customFieldTypeUser and customFieldTypeUserSet types
- Add newCustomFieldTypeUser() constructor for Cloud vs Local
- Handle single-user and multi-user array fields in create and edit
- Pass installationType through to constructCustomFields
- Convert if/else chains to switch (gocritic lint)
- Add comprehensive unit tests (18 new tests)

Fixes ankitpokhrel#798, ankitpokhrel#758, ankitpokhrel#579
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.

Assigning Custom field dataType user as a reviewer

1 participant