Skip to content

🐛 Bitbucket-Pull-Requests: Not using backstage fetchApi #6367

@Tphender91

Description

@Tphender91

Workspace

bitbucket-pull-requests

📜 Description

It looks like the bitbucket-pull-requests plugin is using cross-fetch rather than the backstage/core-plugin-api fetchApi as documented on https://backstage.io/docs/plugins/call-existing-api#using-the-backstage-proxy which is causing 401 errors when hitting the /proxy/api endpoint. Testing locally with switching the fetch calls to this fetchApi.fetch calls seemed to work.

Also it seems like the bitbucket.proxyPath is not being honored and I'm not sure why. It only is ever using the default url of '/bitbucket/api'

👍 Expected behavior

Plugin calling the proxy url should utilize fetchApi so auth is automatically provided.

Also changes to the bitbucket.proxyPath should be honored as defined in the docs.

👎 Actual Behavior with Screenshots

plugin is calling
GET /api/proxy/bitbucket/api/projects/PROD/repos/REPO/pull-requests?limit=50 HTTP/1.1" which has response status of 401
I have the proxy.endpoints configured and working for other endpoints. When updating to fetchApi and not changing other config, it worked fine.

Also I have:
bitbucket:
proxyPath: /bitbucket-prs/api
and it still uses just /api/proxy/bitbucket/api/

👟 Reproduction steps

Install plugin 3.0.0 version, set entity with appropriate annotation, backstage spec of below, debug logs on, hit Card to see 401 for wrong proxy

spec:
proxy:
endpoints:
'/bitbucket-prs/api':
target: https://${BITBUCKET_HOST}
changeOrigin: true
logLevel: debug
headers:
Authorization: Bearer ${BITBUCKET_API_TOKEN}
Accept: 'application/json'
Content-Type: 'application/json'
bitbucket:
proxyPath: /bitbucket-prs/api

📃 Provide the context for the Bug.

https://github.com/backstage/community-plugins/blob/main/workspaces/bitbucket-pull-requests/plugins/bitbucket-pull-requests/src/api/BitbucketApi.ts#L108
https://backstage.io/docs/plugins/call-existing-api#using-the-backstage-proxy

👀 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions