backstage: ๐Ÿ› Bug Report: Github Discovery error

๐Ÿ“œ Description

Problem started when upgrading from 1.7.2 to 1.8.3 and still persists when upgrading to 1.10.1

Iโ€™ve made the changes as advised regarding the naming from GitHub to Github but when the app starts on my local, I get the errors coming from my config for the Github Discovery feature.

I havenโ€™t change anything from the config nor the Github App itself as it was working prior to 1.8.3. Did I miss something in the upgrade?

๐Ÿ‘ Expected behavior

Github Discovery working and able to pull org data from public Github

๐Ÿ‘Ž Actual Behavior with Screenshots

In the console, error reported the following

1] 2023-01-25T06:39:00.172Z catalog error github-provider:providerId refresh failed fetch failed type=plugin target=github-provider:providerId class=GithubEntityProvider taskId=github-provider:providerId:refresh taskInstanceId=ee0f1bf5-5275-4658-88de-b7f3af8d86bb name=HttpError status=500 request=[object Object] stack=HttpError: fetch failed
[1]     at /Users/yungc/Documents/Projects/backstage/node_modules/@octokit/request/dist-node/index.js:99:11
[1]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[1]     at async hook (/Users/yungc/Documents/Projects/backstage/node_modules/@octokit/auth-app/dist-node/index.js:297:18)
[1]     at async Object.next (/Users/yungc/Documents/Projects/backstage/node_modules/@octokit/plugin-paginate-rest/dist-node/index.js:67:28)
[1]     at async GithubAppManager.getInstallationData (/Users/yungc/Documents/Projects/backstage/node_modules/@backstage/integration/dist/index.cjs.js:1311:30)
[1]     at async /Users/yungc/Documents/Projects/backstage/node_modules/@backstage/integration/dist/index.cjs.js:1278:45
[1]     at async Cache.getOrCreateToken (/Users/yungc/Documents/Projects/backstage/node_modules/@backstage/integration/dist/index.cjs.js:1228:34)
[1]     at async Promise.all (index 0)
[1]     at async GithubAppCredentialsMux.getAppToken (/Users/yungc/Documents/Projects/backstage/node_modules/@backstage/integration/dist/index.cjs.js:1349:21)
[1]     at async _SingleInstanceGithubCredentialsProvider.getCredentials (/Users/yungc/Documents/Projects/backstage/node_modules/@backstage/integration/dist/index.cjs.js:1399:17)

In the UI, Catalog Import returns the following error

{"error":{"name":"InputError","message":"Error: Unable to read url, HttpError: fetch failed","stack":"InputError: Error: Unable to read url, HttpError: fetch failed\n at DefaultLocationService.processEntities (/Users/yungc/Documents/Projects/backstage/node_modules/@backstage/plugin-catalog-backend/dist/index.cjs.js:2188:15)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async DefaultLocationService.dryRunCreateLocation (/Users/yungc/Documents/Projects/backstage/node_modules/@backstage/plugin-catalog-backend/dist/index.cjs.js:2219:22)\n at async /Users/yungc/Documents/Projects/backstage/node_modules/@backstage/plugin-catalog-backend/dist/index.cjs.js:3512:22"},"request":{"method":"POST","url":"/locations?dryRun=true"},"response":{"statusCode":400}}

๐Ÿ‘Ÿ Reproduction steps

  1. Run Backstage upgrade as per instructed
  2. Run yarn dev
  3. Error is printed on the console

During runtime,

  1. Go to catalog-import page.
  2. Try to import a catalog
  3. Observe error output on the screen

๐Ÿ“ƒ Provide the context for the Bug.

No response

๐Ÿ–ฅ๏ธ Your Environment

OS: Darwin 22.2.0 - darwin/x64 node: v18.12.1 yarn: 1.22.19 cli: 0.22.1 (installed) backstage: 1.10.1

Dependencies: @backstage/app-defaults 1.1.0 @backstage/backend-app-api 0.3.1 @backstage/backend-common 0.18.1 @backstage/backend-plugin-api 0.3.1 @backstage/backend-tasks 0.4.2 @backstage/backend-test-utils 0.1.33 @backstage/catalog-client 1.3.0 @backstage/catalog-model 1.1.5 @backstage/cli-common 0.1.11 @backstage/cli 0.22.1 @backstage/config-loader 1.1.8 @backstage/config 1.0.6 @backstage/core-app-api 1.4.0 @backstage/core-components 0.11.2, 0.12.3 @backstage/core-plugin-api 1.3.0 @backstage/dev-utils 1.0.11 @backstage/errors 1.1.4 @backstage/integration-aws-node 0.1.1 @backstage/integration-react 1.1.9 @backstage/integration 1.4.2 @backstage/plugin-api-docs 0.8.14 @backstage/plugin-app-backend 0.3.41 @backstage/plugin-auth-backend 0.17.4 @backstage/plugin-auth-node 0.2.10 @backstage/plugin-badges-backend 0.1.35 @backstage/plugin-badges 0.2.38 @backstage/plugin-bazaar-backend 0.2.4 @backstage/plugin-bazaar 0.2.3 @backstage/plugin-catalog-backend-module-github 0.2.4 @backstage/plugin-catalog-backend 1.7.1 @backstage/plugin-catalog-common 1.0.10 @backstage/plugin-catalog-graph 0.2.26 @backstage/plugin-catalog-import 0.9.4 @backstage/plugin-catalog-node 1.3.2 @backstage/plugin-catalog-react 1.2.4 @backstage/plugin-catalog 1.7.2 @backstage/plugin-cost-insights-common 0.1.1 @backstage/plugin-cost-insights 0.12.3 @backstage/plugin-events-node 0.2.2 @backstage/plugin-explore-common 0.0.1 @backstage/plugin-explore-react 0.0.25 @backstage/plugin-explore 0.3.45 @backstage/plugin-github-actions 0.5.14 @backstage/plugin-github-issues 0.2.3 @backstage/plugin-github-pull-requests-board 0.1.8 @backstage/plugin-home 0.4.30 @backstage/plugin-kubernetes-backend 0.9.2 @backstage/plugin-kubernetes-common 0.5.1 @backstage/plugin-kubernetes 0.7.7 @backstage/plugin-org 0.6.4 @backstage/plugin-permission-common 0.7.3 @backstage/plugin-permission-node 0.7.4 @backstage/plugin-permission-react 0.4.9 @backstage/plugin-proxy-backend 0.2.35 @backstage/plugin-scaffolder-backend 1.10.1 @backstage/plugin-scaffolder-common 1.2.4 @backstage/plugin-scaffolder-react 1.0.1 @backstage/plugin-scaffolder 1.10.1 @backstage/plugin-search-backend-module-elasticsearch 1.1.2 @backstage/plugin-search-backend-module-pg 0.5.2 @backstage/plugin-search-backend-node 1.1.2 @backstage/plugin-search-backend 1.2.2 @backstage/plugin-search-common 1.2.1 @backstage/plugin-search-react 1.4.0 @backstage/plugin-search 1.0.7 @backstage/plugin-shortcuts 0.3.6 @backstage/plugin-sonarqube-backend 0.1.6 @backstage/plugin-sonarqube-react 0.1.1 @backstage/plugin-sonarqube 0.6.2 @backstage/plugin-stack-overflow 0.1.10 @backstage/plugin-tech-insights-backend-module-jsonfc 0.1.25 @backstage/plugin-tech-insights-backend 0.5.7 @backstage/plugin-tech-insights-common 0.2.9 @backstage/plugin-tech-insights-node 0.3.9 @backstage/plugin-tech-insights 0.3.6 @backstage/plugin-tech-radar 0.6.0 @backstage/plugin-techdocs-addons-test-utils 1.0.9 @backstage/plugin-techdocs-backend 1.5.2 @backstage/plugin-techdocs-module-addons-contrib 1.0.9 @backstage/plugin-techdocs-node 1.4.5 @backstage/plugin-techdocs-react 1.1.2 @backstage/plugin-techdocs 1.4.3 @backstage/plugin-todo-backend 0.1.38 @backstage/plugin-todo 0.2.16 @backstage/plugin-user-settings 0.6.2 @backstage/release-manifests 0.0.8 @backstage/test-utils 1.2.4 @backstage/theme 0.2.16 @backstage/types 1.0.2 @backstage/version-bridge 1.0.3

๐Ÿ‘€ Have you spent some time to check if this bug has been raised before?

  • I checked and didnโ€™t find similar issue

๐Ÿข Have you read the Code of Conduct?

Are you willing to submit PR?

None

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 18 (10 by maintainers)

Most upvoted comments

For the interest of closure to this issue. Iโ€™ve finally managed to resolve it. Not by using undici package but a setting in Node.

export NODE_OPTIONS="--no-experimental-fetch"

This turns off the experimental fetch api in native node18 and uses the dependency package fetch module instead. This in-turns respects the proxy setting as per documentation. Avoid using experimental feature, Iโ€™d say. ๐Ÿ˜ธ

Source: https://github.com/node-fetch/node-fetch/issues/1566

OK I think iโ€™m starting to understand whatโ€™s going on here. The bump to @octokit/request now will use the native implementation of fetch if itโ€™s available, and it looks like that is the not being wrapped up in the http proxy stuff from global agent. https://github.com/octokit/request.js/pull/481

Then using this information, I had a look at the global-fetch repo and found this: https://github.com/gajus/global-agent/issues/52

Looks like there might be a workaround here at the bottom, but itโ€™s not great. I think once we have the backend system we can maybe have the ability to have a fetch service that can be used everywhere that can add these settings so we wont need the global fetch anymore.

Iโ€™d look at trying to use that workaround to see if it works for you ๐Ÿคž and report back.

Hmm yeah thatโ€™s interesting, I wonder if theyโ€™ve changed how they make requests from @octokit/request@5.6.3 -> @octokit/request@6.2.3 and now the global-agent doesnโ€™t work anymore. If you can find out some more info or a possible route forward would be much appreciated ๐Ÿ™