feat(jira): add createCustomField method to JIRA client and tRPC endpoint#782
feat(jira): add createCustomField method to JIRA client and tRPC endpoint#782
Conversation
nhopeatall
left a comment
There was a problem hiding this comment.
Summary
Clean, well-structured addition that follows existing codebase patterns closely. Two observations worth considering — neither blocking.
Code Issues
Should Fix
- src/jira/client.ts:337 — The error message hardcodes "requires admin permissions" for all failure scenarios (network errors, duplicate field names, validation errors, etc.). Compare with the existing
createIssueerror handler (line 190) which uses a neutral"JIRA createIssue failed"prefix. This will mislead debugging when the root cause isn't permissions. Consider using a neutral prefix like"JIRA createCustomField failed"and mentioning admin permissions only in a hint, e.g.,"JIRA createCustomField failed (admin permissions may be required)".
Nitpick
- src/jira/client.ts:319-321 — The JIRA
createCustomFieldAPI accepts an optionalsearcherKeyparameter. Forfloattype, valid searchers areexactnumberornumberrange. Without specifying one, the created custom field won't be searchable via JQL. If this field will be used for cost tracking/reporting, JQL searchability could be valuable. This could also be addressed later if not needed now.
Replace misleading "requires admin permissions" prefix with neutral "failed (admin permissions may be required)" to avoid confusion when the root cause is a network error, duplicate name, or validation issue. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nhopeatall
left a comment
There was a problem hiding this comment.
Summary
Clean, well-structured PR that follows existing patterns exactly. One functional consideration worth discussing.
Should Consider
- Missing
searcherKeyfor the custom field: ThecreateCustomFieldcall only passesnameandtypeto the JIRA API. Per the jira.js SDK and JIRA REST API docs, omittingsearcherKeymeans the created float field won't be searchable via JQL. For a numeric cost field, passing a searcher likeexactnumberornumberrangewould make the field queryable (e.g.,"Cost" > 100). If this is intentional, a code comment noting the trade-off would be helpful; if not, it's worth adding.
Everything else looks good:
- Client method correctly follows the
createIssueerror-handling pattern (message extraction, response data enrichment, admin permissions hint) - tRPC endpoint follows the
createTrelloCustomFieldpattern (extend creds input,withResolvedJiraCreds, protected procedure) - Type casts and
?? ''fallbacks are consistent withFieldDetailshaving optional fields - Tests are comprehensive: success, missing fields, error enrichment (with/without response data), scope validation, auth, credential resolution, and input validation
- CI is fully green
Pass the exactnumber searcherKey when creating a float custom field so the field is queryable via JQL (e.g. `"Cost" > 100`). The method signature accepts an optional searcherKey param; the tRPC endpoint always passes exactnumber for the hardcoded float type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review Feedback AddressedChanges Made
Verification
|
nhopeatall
left a comment
There was a problem hiding this comment.
LGTM — Clean addition that follows established patterns exactly.
The createCustomField client method mirrors the existing createIssue error handling pattern (enriched error with response detail, admin permissions hint). The tRPC endpoint follows the same withResolvedJiraCreds + withJiraCredentials composition as all other JIRA endpoints in this router. Good design choice keeping the client method general-purpose (type and searcherKey as parameters) while the endpoint hardcodes the specific float/exactnumber values for the cost field use case. Test coverage is thorough across both layers.
Summary
This PR adds support for creating custom fields in JIRA through the dashboard and CLI.
createCustomField(name, type)tojiraClientusing the jira.js SDK'sissueFields.createCustomField()APIcreateJiraCustomFieldmutation to the integrations discovery routerImplementation Details
JIRA Client Method (
src/jira/client.ts)createCustomField(name: string, type: string): Promise<{ id: string; name: string }>getClient().issueFields.createCustomField()from jira.js SDKtRPC Endpoint (
src/api/routers/integrationsDiscovery.ts)createJiraCustomFieldjiraCredsInputwithname: z.string().min(1).max(100)'com.atlassian.jira.plugin.system.customfieldtypes:float'for numeric cost fieldswithResolvedJiraCredshelper for credential resolution and error wrappingTest Coverage
JIRA client tests (5 new tests):
tRPC endpoint tests (6 new tests):
Acceptance Criteria
Tests
All tests passing: