question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Search backend does not work when Backstage API requires auth

See original GitHub issue

Expected Behavior

  • Search backend worker process collates documents successfully

Current Behavior

  • Search backend worker process fails with the error message below as no Authorization header is sent when fetching catalog entities.
2021-04-01T23:38:59.804Z search info Collating documents for software-catalog via DefaultCatalogCollator type=plugin
2021-04-01T23:38:59.810Z backstage info ::ffff:127.0.0.1 - - [01/Apr/2021:23:38:59 +0000] "GET /api/catalog/entities HTTP/1.1" 401 12 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" type=incomingRequest
(node:81127) UnhandledPromiseRejectionWarning: FetchError: invalid json response body at http://localhost:7000/api/catalog/entities reason: Unexpected token U in JSON at position 0
    at /adopter/backstage/node_modules/node-fetch/lib/index.js:272:32
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async DefaultCatalogCollator.execute (/adopter/backstage/node_modules/@backstage/plugin-catalog-backend/dist/index.cjs.js:3268:22)
    at async /adopter/backstage/node_modules/@backstage/plugin-search-backend-node/dist/index.cjs.js:39:23
    at async Promise.all (index 0)
(node:81127) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 16)

Possible Solution

Steps to Reproduce

  1. Follow instructions in https://github.com/backstage/backstage/blob/master/contrib/docs/tutorials/authenticate-api-requests.md on how to require authentication of the backstage api
  2. Start backstage
  3. Look at the logs to see the error message (search backend runs on a timer)

Context

Currently no impact as the search backend is not yet in use I think? When it is, I assume search will break for adopters using API auth.

Your Environment

  • NodeJS Version (v12): v14
  • Operating System and Version (e.g. Ubuntu 14.04): Mac OS X Catalina
  • Browser Information:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
erikxivcommented, Nov 29, 2021

The PR looks like just the thing. Have not tried it yet, but closing this issue with good faith in the implementors.

0reactions
nasquashacommented, Nov 29, 2021

#7943 has been merged! the solution fixes the breaking collators. is this issue alright to close?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Auth
Auth is tricky and doesn't always work as expected. Below you'll find some of the common problems one might run into when setting...
Read more >
backstage/plugin-auth-backend - npm package
Auth Backend. WORK IN PROGRESS. This is the backend part of the auth plugin. It responds to auth requests from the frontend, and...
Read more >
backstage/plugin-auth-backend
A Backstage backend plugin that handles authentication. Latest version: 0.17.1, last published: a month ago.
Read more >
Backstage by Example (Part 2) - John Tucker
If Backstage is configured to use GitHub Apps authentication you must grant ... (and thus be authorized) to use this Backstage App. To...
Read more >
Penetration Test on Backstage
leading to potential authentication and authorization problems. ... No Authentication Required for sca older- backend. NONE. NOT.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found