feat: add support for user-type custom fields#944
Open
alastori wants to merge 1 commit intoankitpokhrel:mainfrom
Open
feat: add support for user-type custom fields#944alastori wants to merge 1 commit intoankitpokhrel:mainfrom
alastori wants to merge 1 commit intoankitpokhrel:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds handling for
user-type custom fields in both create and edit paths.Problem
User-type custom fields passed via
--customare silently dropped. The CLI reports "Issue updated" but the field remains null. This happens because the custom field switch statement only handlesoption,array,number,project, and thedefault(string) cases — but Jira's REST API requires user fields to be objects ({"accountId":"..."}for Cloud,{"name":"..."}for Server/DC), not plain strings.Solution
customFieldTypeUserandcustomFieldTypeUserSettypes following the existing patternnewCustomFieldTypeUser()constructor that branches on Cloud vs Local installationuserschema type for single-user fields in bothconstructCustomFields(create) andconstructCustomFieldsForEdit(edit)useritems type for multi-user picker arrays in both pathsinstallationTypethrough toconstructCustomFieldsin the create path (edit already had it)if/elsechains toswitchin the array sub-cases (gocritic lint)How to test?
Unit tests (18 new tests):
Manual verification:
jira initand map the field in config underissue.fields.customwithdatatype: userjira issue edit TEST-1 --custom "pm-owner=<accountId>" --no-inputTested end-to-end on a real Jira Cloud instance.
Checklist
golangci-lint0 issues)Fixes #798, #758, #579