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.

integrations url processor doesn't implement support for private gitlab repos

See original GitHub issue

Integrations for gitlab private repos do not work; only public repos can be pulled from, e.g. for catalog items.

Expected Behavior

The gitlab API (or different auth headers) need to be used with the token in order to get files from a private repo.

Current Behavior

Fails to load the referenced file.

Possible Solution

Use gitlab API endpoint to retrieve file content?

Steps to Reproduce

  1. Make a private mirror of backstage/backstage.
  2. Create an access token.
  3. Modify example app-config.yaml (e.g. in app-config.local.yaml) to point a scaffolder entry at the private gitlab repo file. For example: the Documentation Template.
  4. Run the demo server with yarn dev
[1] 2021-01-15T15:10:06.774Z catalog warn Failed item in location url:https://gitlab.cc.columbia.edu/cuit-ent-arch/backstage/blob/master/templates/docs-template/template.yaml, Error: YAML error, YAMLSemanticError: Implicit map keys need to be on a single line
[1]     at Module.generalError (webpack-internal:///../../plugins/catalog-backend/src/ingestion/processors/results.ts:59:56)
[1]     at parseEntityYaml (webpack-internal:///../../plugins/catalog-backend/src/ingestion/processors/util/parse.ts:45:66)
[1]     at parseEntityYaml.next (<anonymous>)
[1]     at UrlReaderProcessor.readLocation (webpack-internal:///../../plugins/catalog-backend/src/ingestion/processors/UrlReaderProcessor.ts:64:18)
[1]     at processTicksAndRejections (internal/process/task_queues.js:97:5)
[1]     at async LocationReaders.handleLocation (webpack-internal:///../../plugins/catalog-backend/src/ingestion/LocationReaders.ts:142:13)
[1]     at async LocationReaders.read (webpack-internal:///../../plugins/catalog-backend/src/ingestion/LocationReaders.ts:74:11)
[1]     at async HigherOrderOperations.refreshSingleLocation (webpack-internal:///../../plugins/catalog-backend/src/ingestion/HigherOrderOperations.ts:159:26)
[1]     at async HigherOrderOperations.refreshAllLocations (webpack-internal:///../../plugins/catalog-backend/src/ingestion/HigherOrderOperations.ts:138:9)
[1]     at async startRefresh (webpack-internal:///../../plugins/catalog-backend/src/util/runPeriodically.ts:42:9) type=plugin

Tracing the code shows https://github.com/backstage/backstage/blob/9d7b50f2f36f599df4c9ceacb18676fc0fdf72bc/packages/backend-common/src/reading/GitlabUrlReader.ts#L56 generates a GET with a PRIVATE-TOKEN header.

Gitlab only supports the PRIVATE-TOKEN header for the API, not file URLs.

Context

Trying to use backstage with private repos (on prem gitlab enterprise and/or github.com) and can’t reference individual git-hosted files with the url processor.

The current workaround is to make the repos public.

Your Environment

  • NodeJS Version (v12): v12.20.0
  • Operating System and Version (e.g. Ubuntu 14.04): MacOS Catalina 10.15.7 (19H114)
  • Browser Information: N/A

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

4reactions
rulowebcommented, Jan 18, 2021

@n2ygk all you have to do is to add a -/ in the URL xD, like this:

https://gitlab.cc.columbia.edu/cuit-ent-arch/backstage/-/blob/master/templates/docs-template/template.yaml

This is because of the logic in the getGitLabFileFetchUrl function, if the URL contains -/ it will use the API, otherwise, it will do a simple fetch.

https://github.com/backstage/backstage/blob/master/packages/integration/src/gitlab/core.ts#L41

It could be rewritten following the same logic as the github integration, what do you think @freben?.

2reactions
n2ygkcommented, Jan 18, 2021

Huh. scoped URLs. Go figure… Didn’t even know that was a thing. Aha! I see that our gitlab instance is on an old version (11.11.0) while newer versions will remove the legacy (no-dash) URLs so that will be a non-issue going forward.

Thanks @ruloweb!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Project integrations - GitLab Docs
Integration Description Integration hooks Asana Add commit messages as comments to Asana tasks. No Assembla Manage projects. No Atlassian Bamboo CI Run CI/CD pipelines with Atlassian...
Read more >
Control access and visibility - GitLab Docs
GitLab enables users with administrator access to enforce specific controls on branches, projects, snippets, groups, and more. To access the visibility and ...
Read more >
Projects API - GitLab Docs
If your HTTP repository isn't publicly accessible, add authentication information to the URL https://username:password@gitlab.company.com/group/project.git , ...
Read more >
GitLab CI/CD for external repositories
Select GitHub or Repository by URL. ... This feature does not support: ... If you want help with something specific and could use...
Read more >
Integrate with GitLab CI/CD | YouTrack Server Documentation
The integration between YouTrack and GitLab CI/CD enables useful features in both applications: Pull pipeline IDs from connected projects in ...
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