Skip to content

Commit 1475553

Browse files
committed
fix(jira): use Accept: */* when downloading attachment content (#577)
The Jira attachment-content endpoint (`/rest/api/3/attachment/content/{id}`) serves the file's own media type and responds 406 Not Acceptable to a narrow `Accept: application/octet-stream`. That made every attachment download fail with HTTP 406, and the fail-closed path then rejected the whole task ("could not be downloaded (HTTP 406)"). Send `Accept: */*` so the gateway serves the real content type. Verified against the live endpoint: octet-stream → 406, */* → 200. Test asserts the download request sets Accept: */*.
1 parent 25612ca commit 1475553

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

cdk/src/handlers/shared/jira-attachments.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@ async function fetchAttachmentBytes(
264264
method: 'GET',
265265
headers: {
266266
Authorization: `Bearer ${accessToken}`,
267-
Accept: 'application/octet-stream',
267+
// The attachment-content endpoint returns the file's own content type
268+
// (image/jpeg, application/pdf, …) and responds 406 Not Acceptable to a
269+
// narrow `Accept: application/octet-stream`. Accept anything so the
270+
// gateway can serve the real media type.
271+
Accept: '*/*',
268272
},
269273
signal: controller.signal,
270274
});

cdk/test/handlers/shared/jira-attachments.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ describe('downloadScreenAndStoreJiraAttachments', () => {
141141
// GET was addressed by attachment id on the gateway base, not the raw content URL.
142142
const fetchUrl = (global.fetch as jest.Mock).mock.calls[0][0] as string;
143143
expect(fetchUrl).toContain('api.atlassian.com/ex/jira/cloud-1/rest/api/3/attachment/content/att-1');
144+
// Accept must be permissive: the content endpoint 406s on
145+
// `application/octet-stream` and serves the file's own media type.
146+
const fetchInit = (global.fetch as jest.Mock).mock.calls[0][1] as { headers: Record<string, string> };
147+
expect(fetchInit.headers.Accept).toBe('*/*');
144148
});
145149

146150
test('routes images through screenImage and marks type image', async () => {

0 commit comments

Comments
 (0)