Cloning a toplevel group wiki over HTTP fails with error 500 / JWT::DecodeError
Summary
The Git support for group wikis added in !45892 (merged) fails when trying to clone a toplevel group wiki over HTTP.
Other cases (cloning a child group wiki over HTTP, or cloning a toplevel/child group wiki over SSH) work fine.
Steps to reproduce
$ git clone https://staging.gitlab.com/group-wikis-testing.wiki.git
fatal: unable to access 'https://staging.gitlab.com/group-wikis-testing.wiki.git/': The requested URL returned error: 500
$ git clone https://staging.gitlab.com/group-wikis-testing/subgroup.wiki.git
Cloning into 'subgroup.wiki'...
Username for 'https://staging.gitlab.com':
What is the current bug behavior?
The clone fails with a 500 error.
What is the expected correct behavior?
The clone should succeed without errors.
Relevant logs and/or screenshots
See Sentry errors:
- https://sentry.gitlab.net/gitlab/staginggitlabcom/issues/2418790/
- https://sentry.gitlab.net/gitlab/gitlabcom/issues/2400244/
Output of checks
This bug happens on GitLab.com
Possible fixes
Git HTTP requests are intercepted by Workhorse, which injects the JWT for authentication with the Rails app.
This currently only matches nested .git
paths, but not toplevel paths: https://gitlab.com/gitlab-org/gitlab-workhorse/blob/38a07d72308788043c364f92fdf7bf570cbb000b/internal/upstream/routes.go#L58
We can probably just tweak this regex to only require a single path component. This would also align with the changes in !45872 (merged).
We could also rename the variable to e.g. gitRepositoryPattern
, since it's not exclusively for project repositories (this was already the case with personal snippets, before we added group wikis).