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

Error 404 on RepositoryFiles.showRaw missing ref #1990

Closed
baudouindesvaux opened this issue Aug 5, 2021 · 4 comments
Closed

Error 404 on RepositoryFiles.showRaw missing ref #1990

baudouindesvaux opened this issue Aug 5, 2021 · 4 comments

Comments

@baudouindesvaux
Copy link

baudouindesvaux commented Aug 5, 2021

Description

I use @gitbeaker/browser
When using RepositoryFiles.showRaw, I receive a 404 error. The url is /projects/:id/repository/files/:file_path/raw, when I try this url in Postman, I have this message : {"error": "ref is missing, ref is empty"}, but if I add ?ref=branch, that's works !

Steps to reproduce

Use RepositoryFiles.showRaw like :

import { Gitlab } from '@gitbeaker/browser';

const api = new Gitlab({
  host : 'url',
  token : 'token'
})

api.RepositoryFiles.showRaw(idProject,"file").then((data)=>{
  console.log(data)
})

Expected behaviour

See the file

Actual behaviour

404 error {"error": "ref is missing, ref is empty"}

Possible fixes

Add ref parameter to showRaw method on RepositoryFiles.ts file maybe like this :

showRaw(projectId: string | number, filePath: string, ref: string, options ?: BaseRequestOptions) {
  const [pId, path] = [projectId, filePath].map(encodeURIComponent);

  return RequestHelper.get()(
    this,
    `projects/${pId}/repository/files/${path}/raw`,
    {
      ref,
      ...options,
    }
  ) as unknown as Promise<Blob>;
}
@jdalrymple
Copy link
Owner

jdalrymple commented Aug 9, 2021

Yea the fix you mentioned should solve this. Ill whip up the PR at some point today!

@jdalrymple
Copy link
Owner

hmm

this is weird, in the docs it still says its optional? https://docs.gitlab.com/ee/api/repository_files.html#get-raw-file-from-repository

@baudouindesvaux
Copy link
Author

Yes, I see that...
It's optional for 14.X but my company's version of gitlab it's 13.10... And on 13.X it's required... https://docs.gitlab.com/13.12/ee/api/repository_files.html#get-file-from-repository
I don't know when they have plan to upgrade GitLab...

@jdalrymple
Copy link
Owner

ah, hmm, Im really aiming to improve the version control for 14 going forward to avoid these kind of problems. Making it a required parameter would be a bit of a regression for now. I know its a pain, but the best move for you would probs just be passing the param to your logic like you did. I will add information for the supported gitlab version going forward though. I've been meaning to do this with #1592

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants