Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Orchestrator Backend] The catalog:register action attempts to create a location with a target of null. #1167

Closed
Zaperex opened this issue Feb 2, 2024 · 1 comment · Fixed by #1199
Labels
jira kind/bug Something isn't working status/triage

Comments

@Zaperex
Copy link
Member

Zaperex commented Feb 2, 2024

Describe the bug

When trying to utilize the orchestrator plugin, and running one of the create backend app workflows in the example workflow repository such as the spring-boot-backend workflow, the workflow will create the repository but will not be able to register the corresponding component. Instead it will output the following in the logs saying it's registering null into the catalog:

backend:start: 2024-02-02T18:33:29.380Z orchestrator info Registering null in the catalog 
backend:start: 2024-02-02T18:33:29.389Z rootHttpRouter info ::1 - - [02/Feb/2024:18:33:29 +0000] "POST /locations HTTP/1.1" 400 - "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" type=incomingRequest
backend:start: 2024-02-02T18:33:29.413Z backstage error Request failed with status 500 {"error":{"name":"InputError","message":"request/body/target must be string","stack":"InputError: request/body/target must be string\n    at <anonymous> (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/@backstage/backend-openapi-utils/src/stub.ts:42:10)\n    at handleReturn (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express-promise-router/lib/express-promise-router.js:24:23)\n    at /home/frkong/coding/janus-idp/backstage-showcase/node_modules/express-promise-router/lib/express-promise-router.js:55:9\n    at Layer.handle_error (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/layer.js:71:5)\n    at trim_prefix (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:326:13)\n    at /home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:286:9\n    at Function.process_params (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:346:12)\n    at next (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:280:10)\n    at Layer.handle_error (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/layer.js:67:12)\n    at trim_prefix (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:326:13)\n    at /home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:286:9\n    at Function.process_params (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:346:12)\n    at next (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:280:10)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"},"request":{"method":"POST","url":"/locations"},"response":{"statusCode":400}} type=errorHandler stack=Error: {"error":{"name":"InputError","message":"request/body/target must be string","stack":"InputError: request/body/target must be string\n    at <anonymous> (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/@backstage/backend-openapi-utils/src/stub.ts:42:10)\n    at handleReturn (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express-promise-router/lib/express-promise-router.js:24:23)\n    at /home/frkong/coding/janus-idp/backstage-showcase/node_modules/express-promise-router/lib/express-promise-router.js:55:9\n    at Layer.handle_error (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/layer.js:71:5)\n    at trim_prefix (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:326:13)\n    at /home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:286:9\n    at Function.process_params (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:346:12)\n    at next (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:280:10)\n    at Layer.handle_error (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/layer.js:67:12)\n    at trim_prefix (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:326:13)\n    at /home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:286:9\n    at Function.process_params (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:346:12)\n    at next (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/express/lib/router/index.js:280:10)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"},"request":{"method":"POST","url":"/locations"},"response":{"statusCode":400}}
backend:start:     at CatalogClient.addLocation (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/@backstage/catalog-client/src/CatalogClient.ts:325:13)
backend:start:     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
backend:start:     at Object.handler (/home/frkong/coding/janus-idp/backstage-showcase/node_modules/@backstage/plugin-scaffolder-backend/src/scaffolder/actions/builtin/catalog/register.ts:130:9)
backend:start:     at ScaffolderService.executeAction (/home/frkong/coding/janus-idp/backstage-showcase/dynamic-plugins-root/orchestrator-backend/src/service/ScaffolderService.ts:99:11)
backend:start:     at <anonymous> (/home/frkong/coding/janus-idp/backstage-showcase/dynamic-plugins-root/orchestrator-backend/src/service/router.ts:516:31)

Debugging the backend shows that the body field of the request req seems to have an invalid schema (contains the catalogInfoUrl field) when the schema for the action in the upstream has catalogInfoUrl be mutually exclusive with repoContentsUrl and catalogInfoPath:
image

When testing with the regular scaffolder, the body field does not contain the catalogInfoUrl field. Used the sprint-boot-backend scaffolder action.
image

This in turn breaks the logic for the catalog:register action in the scaffolder-backend, resulting in a null catalogInfoUrl field being passed as the target field for the addLocations function of the catalog-client.
image
image

Expected Behavior

The catalog entity is registered into the catalog without any issues

What are the steps to reproduce this bug?

  1. Setup the orchestrator frontend and backend plugin into the backstage-showcase (I dynamically installed them)
  2. Have a valid github app or github token with permissions to create repositories, edit workflows, and repository content
  3. Start the spring-boot-backend workflow
  4. Observe that no catalog entity was ingested into the catalog (since location wasn't added properly)
  5. Observe the backend logs above

Versions of software used and environment

@Zaperex Zaperex added kind/bug Something isn't working status/triage labels Feb 2, 2024
@github-actions github-actions bot added the jira label Feb 2, 2024
@pkliczewski
Copy link

@caponetto fyi

@Zaperex Zaperex changed the title [Orchestrator Backend] The catalog:register attempts to create a location with a target of null. [Orchestrator Backend] The catalog:register action attempts to create a location with a target of null. Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira kind/bug Something isn't working status/triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants