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

private deployment request error #69

Closed
BrightVan opened this issue Jul 30, 2021 · 16 comments
Closed

private deployment request error #69

BrightVan opened this issue Jul 30, 2021 · 16 comments

Comments

@BrightVan
Copy link

https://server_domain/api/v4/projects/group_name%2Fproject_name/repository/tree?per_page=10000&ref=master

this requets url is not work. get status code 404
i found another extenssion gitlab-code-view, can work well,and it's request url like this:

https://server_domain/group_name/project_name/files/master?format=json
@tavyandy97
Copy link
Owner

Hey @BrightVan !

Thank you for reporting the issue, I assume you're using an older version of GitLab (i.e. lesser than v12). Could you please confirm your GitLab version?

The reason the latter API wasn't used to form a tree was for optimization purposes. It returns an array of all the filepaths, and in case of repositories with larger number of files (i.e. greater than 10,000) it would require a lot of parsing.

Therefore the v4 API was chosen to lazy load all the contents of the tree, rather than loading them all at once. It avoids the string parsing overhead along with fetching only the content that is required.

@BrightVan
Copy link
Author

Hey @tavyandy97 !
my gitlab version is 12.7.5
image

@tavyandy97
Copy link
Owner

tavyandy97 commented Jul 30, 2021

@BrightVan
After looking at the documentation of GitLab v12.10, I verified that the route does exist and shouldn't have thrown a 404.

Is there any error message with the 404 error? Also, could you please match the API being called with the one mentioned in the documentation?

@BrightVan
Copy link
Author

@tavyandy97
So , maybe the reason is my gitlab version is too low? the V12.7.5 does not support that route?

@tavyandy97
Copy link
Owner

@BrightVan
Checked the GitLab Archived documentation for v12.7 and seems like the route does exist. After looking around this seems to be an issue with rails and not with GitLab.

Check the following links out

  1. StackOverflow - throws 404 page not found
  2. 404s for no apparent reason

@BrightVan
Copy link
Author

i found the bug:
you should use project id number, but not group_name%2Fproject_name
the api below is ok, just like the offcial document:

https://gitlab.example.com/api/v4/projects/{id}/repository/tree

request like below, response 404 error.

https://gitlab.example.com/api/v4/projects/group_name%2Fproject_name/repository/tree

i do not know why your request url contact with projects/group_name%2Fproject_name but not id

@BrightVan
Copy link
Author

conclusion:
compat api:

https://server_domain/group_name/project_name/files/master?format=json
// it response 301 and will redirect to :
https://server_domain/group_name/project_name/~/files/master?format=json

normal api:

https://gitlab.example.com/api/v4/projects/group_name%2Fproject_name/repository/tree

both api work fine with gitlab.com

but in my private deployment gitlab(i upgrade from 12.7.5 to 14.1.2)
normal api test by chrome response 404, unless replace the group_name%2Fproject_name to project_id, the response OK;
compat api test by chrome response OK, i enabled extension's compat mode, but the extension can not work, response is not 301, can not redirect and get data.

@tavyandy97
Copy link
Owner

The files/master?format=json API is used for the Searchbar popup which is triggered using Ctrl/command+p. However, the projects/group_name%2Fproject_name/repository/tree API is used for displaying the tree in the left-side pane.

This still seems to be a rails configuration issue on your private deployment. I do agree that instead of group_name%2Fproject_name, project_id could have been used.

Could you confirm in your older Gitlab v12.x.x deployment whether a data-project-id attribute exists in the body (on a repository's page)?
Once confirmed we can start using project_id instead of group_name%2Fproject_name.

@tavyandy97
Copy link
Owner

To answer your question, group_name%2Fproject_name was used as per the GitLab documentation. It states both ID or URL encoded path of the project can be used.

@BrightVan
Copy link
Author

BrightVan commented Aug 11, 2021

The files/master?format=json API is used for the Searchbar popup which is triggered using Ctrl/command+p. However, the projects/group_name%2Fproject_name/repository/tree API is used for displaying the tree in the left-side pane.

This still seems to be a rails configuration issue on your private deployment. I do agree that instead of group_name%2Fproject_name, project_id could have been used.

Could you confirm in your older Gitlab v12.x.x deployment whether a data-project-id attribute exists in the body (on a repository's page)?
Once confirmed we can start using project_id instead of group_name%2Fproject_name.

i see a old version(12.7.5) project screenshot, the project_id exist. and what rails configuration should i modefier? i can not find relevant document

@tavyandy97
Copy link
Owner

My bad, in the issue I mentioned earlier, one of the cases seems to be the group_name%2Fproject_name having a . character in it. I assume there'll be other cases as well in which it might return a 404.

I'll start working on the changes, and let you know when they've been released.

Thanks again for reporting the issue 👍

@tavyandy97
Copy link
Owner

Hey @BrightVan !

The issue has been resolved and merged. The version (v0.0.4.3) has been updated to the Chrome Webstore. Will be updating it on Mozilla Addons soon. Would appreciate it if you could verify the fix on your private deployment, and let me know if it works.

Feel free to provide more feedback! Do spread the word about SpanTree 🌳

@BrightVan
Copy link
Author

BrightVan commented Aug 12, 2021

Hey @BrightVan !

The issue has been resolved and merged. The version (v0.0.4.3) has been updated to the Chrome Webstore. Will be updating it on Mozilla Addons soon. Would appreciate it if you could verify the fix on your private deployment, and let me know if it works.

Feel free to provide more feedback! Do spread the word about SpanTree 🌳

Hey @tavyandy97

Thank you for your work.
theprojects/project_id/repository/tree API works well. it's enough for me!
but the files/master?format=json API can not work.

i think it's gitlab's bug, the reason is the page is https, but the redirect url is http, chrome block it (blocked:mixed-content).

and gitlab's page does not add:

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

@tavyandy97
Copy link
Owner

Could you try switching off Compatibility Mode?

Compatibility Mode uses the API /files/master?format=json, which causes a redirection to /-/files/master?format=json. With Compatibility Mode turned off, there will be no redirection and the extentsion will use /-/files/master?format=json.

image

@BrightVan
Copy link
Author

Could you try switching off Compatibility Mode?

Compatibility Mode uses the API /files/master?format=json, which causes a redirection to /-/files/master?format=json. With Compatibility Mode turned off, there will be no redirection and the extentsion will use /-/files/master?format=json.

image

after swithing off Compat Mode, it work well, thanks

@tavyandy97
Copy link
Owner

Closing the issue for now.

Feel free to open a new issue in case you run into an error or have any other concerns. Do spread the word about SpanTree 🌳

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