Skip to content

Commit 4589f16

Browse files
chore: remove feature flag to error builds if failed to fetch extensions (#6048)
1 parent 1679aff commit 4589f16

File tree

4 files changed

+15
-106
lines changed

4 files changed

+15
-106
lines changed

packages/config/src/api/site_info.ts

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ export const getSiteInfo = async function ({
3636
offline = false,
3737
testOpts = {},
3838
siteFeatureFlagPrefix,
39-
featureFlags = {},
4039
}: GetSiteInfoOpts) {
4140
const { env: testEnv = false } = testOpts
42-
const errorOnExtensionFetchFail = featureFlags.error_builds_on_extension_fetch_fail
4341

4442
if (api === undefined || mode === 'buildbot' || testEnv) {
4543
const siteInfo: { id?: string; account_id?: string } = {}
@@ -48,9 +46,7 @@ export const getSiteInfo = async function ({
4846
if (accountId !== undefined) siteInfo.account_id = accountId
4947

5048
const integrations =
51-
mode === 'buildbot' && !offline
52-
? await getIntegrations({ siteId, testOpts, offline, accountId, errorOnExtensionFetchFail })
53-
: []
49+
mode === 'buildbot' && !offline ? await getIntegrations({ siteId, testOpts, offline, accountId }) : []
5450

5551
return { siteInfo, accounts: [], addons: [], integrations }
5652
}
@@ -59,7 +55,7 @@ export const getSiteInfo = async function ({
5955
getSite(api, siteId, siteFeatureFlagPrefix),
6056
getAccounts(api),
6157
getAddons(api, siteId),
62-
getIntegrations({ siteId, testOpts, offline, accountId, errorOnExtensionFetchFail }),
58+
getIntegrations({ siteId, testOpts, offline, accountId }),
6359
]
6460

6561
const [siteInfo, accounts, addons, integrations] = await Promise.all(promises)
@@ -113,15 +109,13 @@ type GetIntegrationsOpts = {
113109
accountId?: string
114110
testOpts: TestOptions
115111
offline: boolean
116-
errorOnExtensionFetchFail?: boolean
117112
}
118113

119114
const getIntegrations = async function ({
120115
siteId,
121116
accountId,
122117
testOpts,
123118
offline,
124-
errorOnExtensionFetchFail,
125119
}: GetIntegrationsOpts): Promise<IntegrationResponse[]> {
126120
if (!siteId || offline) {
127121
return []
@@ -136,31 +130,19 @@ const getIntegrations = async function ({
136130
? `${baseUrl}team/${accountId}/integrations/installations/meta/${siteId}`
137131
: `${baseUrl}site/${siteId}/integrations/safe`
138132

139-
if (errorOnExtensionFetchFail) {
140-
try {
141-
const response = await fetch(url)
142-
if (!response.ok) {
143-
throw new Error(`Unexpected status code ${response.status} from fetching extensions`)
144-
}
145-
const bodyText = await response.text()
146-
if (bodyText === '') {
147-
return []
148-
}
149-
150-
const integrations = await JSON.parse(bodyText)
151-
return Array.isArray(integrations) ? integrations : []
152-
} catch (error) {
153-
return throwUserError(
154-
`Failed retrieving extensions for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`,
155-
)
156-
}
157-
}
158-
159133
try {
160134
const response = await fetch(url)
161-
const integrations = await response.json()
135+
if (!response.ok) {
136+
throw new Error(`Unexpected status code ${response.status} from fetching extensions`)
137+
}
138+
const bodyText = await response.text()
139+
if (bodyText === '') {
140+
return []
141+
}
142+
143+
const integrations = await JSON.parse(bodyText)
162144
return Array.isArray(integrations) ? integrations : []
163-
} catch {
164-
return []
145+
} catch (error) {
146+
return throwUserError(`Failed retrieving extensions for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`)
165147
}
166148
}

packages/config/tests/api/snapshots/tests.js.md

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,56 +2250,12 @@ Generated by [AVA](https://avajs.dev).
22502250
"token": "test"␊
22512251
}`
22522252

2253-
## Integrations are not returned if failed to fetch integrations and if flag is true
2253+
## Integrations are not returned if failed to fetch integrations
22542254

22552255
> Snapshot 1
22562256
22572257
'Failed retrieving extensions for site test: Unexpected status code 500 from fetching extensions. Double-check your login status with \'netlify status\' or contact support with details of your error.'
22582258

2259-
## Empty array of integrations are returned if failed to fetch integrations and if flag is false
2260-
2261-
> Snapshot 1
2262-
2263-
`{␊
2264-
"accounts": [],␊
2265-
"addons": [],␊
2266-
"branch": "branch",␊
2267-
"buildDir": "packages/config/tests/api/fixtures/base",␊
2268-
"config": {␊
2269-
"build": {␊
2270-
"environment": {},␊
2271-
"processing": {␊
2272-
"css": {},␊
2273-
"html": {},␊
2274-
"images": {},␊
2275-
"js": {}␊
2276-
},␊
2277-
"publish": "packages/config/tests/api/fixtures/base",␊
2278-
"publishOrigin": "default",␊
2279-
"services": {}␊
2280-
},␊
2281-
"functions": {␊
2282-
"*": {}␊
2283-
},␊
2284-
"headers": [],␊
2285-
"plugins": [],␊
2286-
"redirects": []␊
2287-
},␊
2288-
"configPath": "packages/config/tests/api/fixtures/base/netlify.toml",␊
2289-
"context": "production",␊
2290-
"env": {},␊
2291-
"hasApi": true,␊
2292-
"headersPath": "packages/config/tests/api/fixtures/base/_headers",␊
2293-
"integrations": [],␊
2294-
"redirectsPath": "packages/config/tests/api/fixtures/base/_redirects",␊
2295-
"repositoryRoot": "packages/config/tests/api/fixtures/base",␊
2296-
"siteInfo": {␊
2297-
"account_id": "account1",␊
2298-
"id": "test"␊
2299-
},␊
2300-
"token": "test"␊
2301-
}`
2302-
23032259
## baseRelDir is true if build.base is overridden
23042260

23052261
> Snapshot 1
@@ -2463,9 +2419,3 @@ Generated by [AVA](https://avajs.dev).
24632419
},␊
24642420
"token": "test"␊
24652421
}`
2466-
2467-
## Integrations are not returned if failed to fetch integrations
2468-
2469-
> Snapshot 1
2470-
2471-
'Failed retrieving extensions for site test: Unexpected status code 500 from fetching extensions. Double-check your login status with \'netlify status\' or contact support with details of your error.'
-69 Bytes
Binary file not shown.

packages/config/tests/api/tests.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -419,36 +419,13 @@ test('Integrations are returned if accountId is present and mode is dev', async
419419
t.assert(config.integrations[0].has_build === true)
420420
})
421421

422-
test('Integrations are not returned if failed to fetch integrations and if flag is true', async (t) => {
422+
test('Integrations are not returned if failed to fetch integrations', async (t) => {
423423
const { output } = await new Fixture('./fixtures/base')
424424
.withFlags({
425425
siteId: 'test',
426426
mode: 'buildbot',
427427
accountId: 'account1',
428428
token: 'test',
429-
featureFlags: {
430-
error_builds_on_extension_fetch_fail: true,
431-
},
432-
})
433-
.runConfigServer([
434-
SITE_INFO_DATA,
435-
TEAM_INSTALLATIONS_META_RESPONSE_INTERNAL_SERVER_ERROR,
436-
FETCH_INTEGRATIONS_EMPTY_RESPONSE,
437-
])
438-
439-
t.snapshot(normalizeOutput(output))
440-
})
441-
442-
test('Empty array of integrations are returned if failed to fetch integrations and if flag is false', async (t) => {
443-
const { output } = await new Fixture('./fixtures/base')
444-
.withFlags({
445-
siteId: 'test',
446-
mode: 'buildbot',
447-
accountId: 'account1',
448-
token: 'test',
449-
featureFlags: {
450-
error_builds_on_extension_fetch_fail: false,
451-
},
452429
})
453430
.runConfigServer([
454431
SITE_INFO_DATA,

0 commit comments

Comments
 (0)