File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( ) => {
Original file line number Diff line number Diff 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 } `
You can’t perform that action at this time.
0 commit comments