Skip to content

Commit aeaa7ec

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(atlassian): release sanitized discovery responses
1 parent dd62d81 commit aeaa7ec

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

apps/sim/lib/atlassian/discovery.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,14 @@ describe('resolveAtlassianCloudId', () => {
124124
})
125125

126126
it('omits provider response bodies from selector discovery errors', async () => {
127-
fetchMock.mockResolvedValue(failure(403, { marker: 'provider-body-secret-marker' }))
127+
const cancel = vi.fn().mockResolvedValue(undefined)
128+
fetchMock.mockResolvedValue(
129+
createMockResponse({
130+
status: 403,
131+
json: { marker: 'provider-body-secret-marker' },
132+
body: { cancel },
133+
})
134+
)
128135

129136
const error = await resolveAtlassianCloudId(
130137
options({
@@ -134,6 +141,7 @@ describe('resolveAtlassianCloudId', () => {
134141

135142
expect(error.message).toBe('Failed to fetch Jira accessible resources: 403')
136143
expect(error.message).not.toContain('provider-body-secret-marker')
144+
expect(cancel).toHaveBeenCalledOnce()
137145
})
138146

139147
it('omits malformed successful response bodies from selector discovery errors', async () => {

apps/sim/lib/atlassian/discovery.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ export function fetchAtlassianDiscoveryJson<T>(
161161
})
162162

163163
if (!response.ok) {
164+
if (omitResponseBodyFromErrors) {
165+
try {
166+
await response.body?.cancel()
167+
} catch {
168+
// Releasing an unread provider body is best-effort; the public error stays sanitized.
169+
}
170+
}
164171
const errorDetail = omitResponseBodyFromErrors
165172
? ''
166173
: ` - ${(await response.text()) || response.statusText}`

0 commit comments

Comments
 (0)