Skip to content

.get returns null for private gitlab projects #30

Description

@detj

Describe the bug
.get() does not return the data for a GitLab private repository. It works perfectly fine & returns data for public GitLab projects though.

Example code that doesn't work

const gitrows = new GitRows({
  token: "xxxxxxxxxxxx",  // a valid gitlab access token with api access to the project
});

const results = await gitrows.get("@gitlab/owner/reponame/path/to/data.json");
console.log(results)  // null

Example code that works

const gitrows = new GitRows({
  server: "git.nomics.world"
});
const results = await gitrows.get("@gitlab/dbnomics-json-data/oecd-json-data/ADIMA/dataset.json");
console.log(results)  // logs the correct data

To Reproduce
Steps to reproduce the behavior:

  1. Create a private repository in gitlab.com with a JSON data file in it
  2. Create a personal access token with api access
  3. Configure a new GitRows instance with the token
  4. Make a .get() call by supplying a correctly formed url

Expected behavior
The promise returned by .get() resolves to null. It should resolve to an object having the same data as exists in the repo .json file.

Additional context
Upon some debugging, I found that the response returned for the network request contains the full HTML payload, as if the request is being made by a browser. The code tries to parse HTML code as JSON which obviously fails and is caught accordingly thereby returning null. This is happening most likely because the network request URL that is supposed to fetch the data doesn't contain the token anywhere in its URL or headers. The GItLab host is not able to authenticate & thus responds with HTML payload for its login page.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions