Skip to content

Commit e08f208

Browse files
committed
fix(jira): keep explicit assignee ahead of customFields and accept string includeAttachments
1 parent 9e42970 commit e08f208

3 files changed

Lines changed: 49 additions & 5 deletions

File tree

‎apps/sim/blocks/blocks/jira.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,10 @@ Return ONLY the comment text - no explanations.`,
11841184
...baseParams,
11851185
issueKey: effectiveIssueKey,
11861186
...(effectiveProjectId && { projectId: effectiveProjectId }),
1187-
includeAttachments: params.includeAttachments === true ? true : undefined,
1187+
includeAttachments:
1188+
params.includeAttachments === true || params.includeAttachments === 'true'
1189+
? true
1190+
: undefined,
11881191
}
11891192
}
11901193
case 'read-bulk': {
@@ -1266,7 +1269,10 @@ Return ONLY the comment text - no explanations.`,
12661269
return {
12671270
...baseParams,
12681271
issueKey: effectiveIssueKey,
1269-
includeAttachments: params.includeAttachments === true ? true : undefined,
1272+
includeAttachments:
1273+
params.includeAttachments === true || params.includeAttachments === 'true'
1274+
? true
1275+
: undefined,
12701276
}
12711277
}
12721278
case 'add_attachment': {

‎apps/sim/lib/internal/jira/operations.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,35 @@ describe('Jira operations', () => {
104104
expect(result.output).not.toHaveProperty('assigneeId')
105105
})
106106

107+
it('keeps the explicit assignee ahead of a customFields assignee on create', async () => {
108+
mocks.request
109+
.mockResolvedValueOnce({
110+
ok: true,
111+
status: 201,
112+
statusText: 'Created',
113+
text: '{"id":"100","key":"PROJ-1","self":"jira-self","fields":{"summary":"Created"}}',
114+
})
115+
.mockResolvedValueOnce({ ok: true, status: 204, statusText: 'No Content', text: '' })
116+
117+
await executeJiraWrite(
118+
{
119+
accessToken: 'token',
120+
domain: 'example.atlassian.net',
121+
projectId: 'PROJ',
122+
summary: 'Created',
123+
assignee: 'account-explicit',
124+
customFields: { assignee: { accountId: 'account-other' }, customfield_10020: 5 },
125+
},
126+
context
127+
)
128+
129+
const createBody = JSON.parse(String((mocks.request.mock.calls[0]?.[1] as RequestInit).body))
130+
expect(createBody.fields).not.toHaveProperty('assignee')
131+
expect(createBody.fields.customfield_10020).toBe(5)
132+
const assignBody = JSON.parse(String((mocks.request.mock.calls[1]?.[1] as RequestInit).body))
133+
expect(assignBody).toEqual({ accountId: 'account-explicit' })
134+
})
135+
107136
it('rejects unsafe attachment issue keys before file or provider work', async () => {
108137
await expect(
109138
executeJiraAddAttachment(

‎apps/sim/lib/internal/jira/operations.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,19 @@ function toParentReference(parent: NonNullable<JiraWriteInput['parent']>): unkno
105105
return /^\d+$/.test(parent) ? { id: parent } : { key: parent }
106106
}
107107

108-
function putAdditionalFields(fields: JsonObject, customFields: JsonObject | undefined): void {
108+
/**
109+
* Merges `customFields` under the explicit fields. `reserved` names fields an explicit
110+
* param sets outside this body (the create flow assigns after creation), which
111+
* `customFields` must not override either.
112+
*/
113+
function putAdditionalFields(
114+
fields: JsonObject,
115+
customFields: JsonObject | undefined,
116+
reserved: string[] = []
117+
): void {
109118
if (!customFields) return
110119
for (const [fieldId, value] of Object.entries(customFields)) {
111-
if (!(fieldId in fields)) fields[fieldId] = value
120+
if (!(fieldId in fields) && !reserved.includes(fieldId)) fields[fieldId] = value
112121
}
113122
}
114123

@@ -163,7 +172,7 @@ export async function executeJiraWrite(input: JiraWriteInput, context: JiraOpera
163172
putOptionalIssueFields(fields, input, false)
164173
if (input.parent) fields.parent = toParentReference(input.parent)
165174
if (input.reporter) fields.reporter = { accountId: input.reporter }
166-
putAdditionalFields(fields, input.customFields)
175+
putAdditionalFields(fields, input.customFields, input.assignee ? ['assignee'] : [])
167176

168177
const response = await client.request(
169178
client.issuePath(),

0 commit comments

Comments
 (0)