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

Fetching GitLab repo contents correctly uses the ref argument #7351

Conversation

maciej-gol
Copy link
Contributor

@maciej-gol maciej-gol commented May 22, 2023

Dependabot can properly list GitLab repo contents on a given branch/commit.

This is problematic when you are, for example, testing dependabot config and the requirements files are not present on the main repository branch, but on the changed branch only. In such case, dependabot won't see expected requirements, resulting in Dependabot::DependencyFileNotFound.

Context

According to the GitLab API (https://docs.gitlab.com/ee/api/repositories.html#list-repository-tree), you have to use the ref argument to list the repository at a given commit/branch.

The GitLab client blindly passes all the arguments to the API itself, including the ref_name argument. GitLab ignores extra GET parameters, thus it wasn't erroring out.

@maciej-gol maciej-gol requested a review from a team as a code owner May 22, 2023 10:27
@maciej-gol maciej-gol force-pushed the mgol/gitlab_repo_tree_correctly_lists_files_for_ref branch from a07f879 to a35fd73 Compare May 25, 2023 16:10
@maciej-gol
Copy link
Contributor Author

Mind having a look into this?

@jurre
Copy link
Member

jurre commented Jun 5, 2023

The change looks good to me, we have some internal stability work that the team is prioritizing so I'll need to hold off merging this for a bit. One thing that I would love to see is some sort of test that would catch this in the future.

@maciej-gol maciej-gol force-pushed the mgol/gitlab_repo_tree_correctly_lists_files_for_ref branch from a35fd73 to df059fb Compare June 11, 2023 14:21
@maciej-gol
Copy link
Contributor Author

Will try to have a look into adding tests, Im not really proficient with ruby

@jurre jurre force-pushed the mgol/gitlab_repo_tree_correctly_lists_files_for_ref branch from df059fb to 4a49493 Compare July 20, 2023 12:25
@jeffwidman jeffwidman force-pushed the mgol/gitlab_repo_tree_correctly_lists_files_for_ref branch from 4a49493 to 8062d1e Compare August 3, 2023 21:55
Copy link
Member

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While a test would be nice, I'm personally okay shipping this as-is w/o any tests because the impact of a regression is relatively small:

  • Won't impact our cloud service at GitHub at all
  • Impact for GitLab users is primarily when their testing on a branch other than main
  • It clearly hasn't been a blocker for folks so far, so it's more of a nice-to-have
  • The Gitlab PR creator is very much community maintained.
  • Long term, we may eventually move away from Ruby-based PR creators to instead doing something with the CLI where it takes job output and has pluggable PR creators... that's a ways off, but it seems reasonable this code may not live forever.

Anyway, all that to say, I think this is fine to ship. If a teammate comes along and feels differently, then I can try to add a test if needed.

Thanks for tracking it down.

@jeffwidman jeffwidman enabled auto-merge (squash) August 3, 2023 21:59
@jeffwidman jeffwidman merged commit fe009bd into dependabot:main Aug 3, 2023
107 checks passed
brettfo pushed a commit to brettfo/dependabot-core that referenced this pull request Oct 11, 2023
…ot#7351)

Dependabot can't properly list GitLab repo contents on a given branch/commit.

This is problematic when you are, for example, testing dependabot config and the requirements files are not present on the main repository branch, but on the changed branch only. In such case, dependabot won't see expected requirements, resulting in `Dependabot::DependencyFileNotFound`.

# Context
According to the GitLab API (https://docs.gitlab.com/ee/api/repositories.html#list-repository-tree), you have to use the `ref` argument to list the repository at a given commit/branch.

The GitLab client blindly passes all the arguments to the API itself, including the `ref_name` argument. GitLab ignores extra GET parameters, thus it wasn't erroring out.
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

Successfully merging this pull request may close these issues.

3 participants