diff --git a/packages/config/src/api/site_info.ts b/packages/config/src/api/site_info.ts index 173384bfb7..e0612918d1 100644 --- a/packages/config/src/api/site_info.ts +++ b/packages/config/src/api/site_info.ts @@ -36,10 +36,8 @@ export const getSiteInfo = async function ({ offline = false, testOpts = {}, siteFeatureFlagPrefix, - featureFlags = {}, }: GetSiteInfoOpts) { const { env: testEnv = false } = testOpts - const errorOnExtensionFetchFail = featureFlags.error_builds_on_extension_fetch_fail if (api === undefined || mode === 'buildbot' || testEnv) { const siteInfo: { id?: string; account_id?: string } = {} @@ -48,9 +46,7 @@ export const getSiteInfo = async function ({ if (accountId !== undefined) siteInfo.account_id = accountId const integrations = - mode === 'buildbot' && !offline - ? await getIntegrations({ siteId, testOpts, offline, accountId, errorOnExtensionFetchFail }) - : [] + mode === 'buildbot' && !offline ? await getIntegrations({ siteId, testOpts, offline, accountId }) : [] return { siteInfo, accounts: [], addons: [], integrations } } @@ -59,7 +55,7 @@ export const getSiteInfo = async function ({ getSite(api, siteId, siteFeatureFlagPrefix), getAccounts(api), getAddons(api, siteId), - getIntegrations({ siteId, testOpts, offline, accountId, errorOnExtensionFetchFail }), + getIntegrations({ siteId, testOpts, offline, accountId }), ] const [siteInfo, accounts, addons, integrations] = await Promise.all(promises) @@ -113,7 +109,6 @@ type GetIntegrationsOpts = { accountId?: string testOpts: TestOptions offline: boolean - errorOnExtensionFetchFail?: boolean } const getIntegrations = async function ({ @@ -121,7 +116,6 @@ const getIntegrations = async function ({ accountId, testOpts, offline, - errorOnExtensionFetchFail, }: GetIntegrationsOpts): Promise { if (!siteId || offline) { return [] @@ -136,31 +130,19 @@ const getIntegrations = async function ({ ? `${baseUrl}team/${accountId}/integrations/installations/meta/${siteId}` : `${baseUrl}site/${siteId}/integrations/safe` - if (errorOnExtensionFetchFail) { - try { - const response = await fetch(url) - if (!response.ok) { - throw new Error(`Unexpected status code ${response.status} from fetching extensions`) - } - const bodyText = await response.text() - if (bodyText === '') { - return [] - } - - const integrations = await JSON.parse(bodyText) - return Array.isArray(integrations) ? integrations : [] - } catch (error) { - return throwUserError( - `Failed retrieving extensions for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`, - ) - } - } - try { const response = await fetch(url) - const integrations = await response.json() + if (!response.ok) { + throw new Error(`Unexpected status code ${response.status} from fetching extensions`) + } + const bodyText = await response.text() + if (bodyText === '') { + return [] + } + + const integrations = await JSON.parse(bodyText) return Array.isArray(integrations) ? integrations : [] - } catch { - return [] + } catch (error) { + return throwUserError(`Failed retrieving extensions for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`) } } diff --git a/packages/config/tests/api/snapshots/tests.js.md b/packages/config/tests/api/snapshots/tests.js.md index 76282a01b6..929e7dc6f1 100644 --- a/packages/config/tests/api/snapshots/tests.js.md +++ b/packages/config/tests/api/snapshots/tests.js.md @@ -2250,56 +2250,12 @@ Generated by [AVA](https://avajs.dev). "token": "test"␊ }` -## Integrations are not returned if failed to fetch integrations and if flag is true +## Integrations are not returned if failed to fetch integrations > Snapshot 1 '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.' -## Empty array of integrations are returned if failed to fetch integrations and if flag is false - -> Snapshot 1 - - `{␊ - "accounts": [],␊ - "addons": [],␊ - "branch": "branch",␊ - "buildDir": "packages/config/tests/api/fixtures/base",␊ - "config": {␊ - "build": {␊ - "environment": {},␊ - "processing": {␊ - "css": {},␊ - "html": {},␊ - "images": {},␊ - "js": {}␊ - },␊ - "publish": "packages/config/tests/api/fixtures/base",␊ - "publishOrigin": "default",␊ - "services": {}␊ - },␊ - "functions": {␊ - "*": {}␊ - },␊ - "headers": [],␊ - "plugins": [],␊ - "redirects": []␊ - },␊ - "configPath": "packages/config/tests/api/fixtures/base/netlify.toml",␊ - "context": "production",␊ - "env": {},␊ - "hasApi": true,␊ - "headersPath": "packages/config/tests/api/fixtures/base/_headers",␊ - "integrations": [],␊ - "redirectsPath": "packages/config/tests/api/fixtures/base/_redirects",␊ - "repositoryRoot": "packages/config/tests/api/fixtures/base",␊ - "siteInfo": {␊ - "account_id": "account1",␊ - "id": "test"␊ - },␊ - "token": "test"␊ - }` - ## baseRelDir is true if build.base is overridden > Snapshot 1 @@ -2463,9 +2419,3 @@ Generated by [AVA](https://avajs.dev). },␊ "token": "test"␊ }` - -## Integrations are not returned if failed to fetch integrations - -> Snapshot 1 - - '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.' diff --git a/packages/config/tests/api/snapshots/tests.js.snap b/packages/config/tests/api/snapshots/tests.js.snap index fcd3582afb..4cf9ceda68 100644 Binary files a/packages/config/tests/api/snapshots/tests.js.snap and b/packages/config/tests/api/snapshots/tests.js.snap differ diff --git a/packages/config/tests/api/tests.js b/packages/config/tests/api/tests.js index 1517273c59..e235c0bbeb 100644 --- a/packages/config/tests/api/tests.js +++ b/packages/config/tests/api/tests.js @@ -419,36 +419,13 @@ test('Integrations are returned if accountId is present and mode is dev', async t.assert(config.integrations[0].has_build === true) }) -test('Integrations are not returned if failed to fetch integrations and if flag is true', async (t) => { +test('Integrations are not returned if failed to fetch integrations', async (t) => { const { output } = await new Fixture('./fixtures/base') .withFlags({ siteId: 'test', mode: 'buildbot', accountId: 'account1', token: 'test', - featureFlags: { - error_builds_on_extension_fetch_fail: true, - }, - }) - .runConfigServer([ - SITE_INFO_DATA, - TEAM_INSTALLATIONS_META_RESPONSE_INTERNAL_SERVER_ERROR, - FETCH_INTEGRATIONS_EMPTY_RESPONSE, - ]) - - t.snapshot(normalizeOutput(output)) -}) - -test('Empty array of integrations are returned if failed to fetch integrations and if flag is false', async (t) => { - const { output } = await new Fixture('./fixtures/base') - .withFlags({ - siteId: 'test', - mode: 'buildbot', - accountId: 'account1', - token: 'test', - featureFlags: { - error_builds_on_extension_fetch_fail: false, - }, }) .runConfigServer([ SITE_INFO_DATA,