Search in all GitLab does not respect relative URL
Summary
Search in all GitLab (option in the search from the top of the page) does not respect relative URL.
Steps to reproduce, behavior and correct behavior
- Set GitLab instance to have relative URL (e.g. http://some_ip_address/gitlab).
- Open GitLab and start typing any search term in the search at the top of the page (e.g. "runner").
- Click on the option that shows up to search in all GitLab (i.e. in this case "runner" in all GitLab).
At this point 404 is given and URL is showing http://some_ip_address/search?search=some instead of search results and URL being http://some_ip_address/gitlab/search?search=some.
Designs
- Show closed items
Relates to
- gitlab #24953Backlog
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Muhamed Huseinbašić added customer label
added customer label
- Author Developer
- Muhamed Huseinbašić assigned to @mhuseinbasic
assigned to @mhuseinbasic
- Muhamed Huseinbašić assigned to @stanhu
assigned to @stanhu
- Muhamed Huseinbašić unassigned @mhuseinbasic
unassigned @mhuseinbasic
- Author Developer
@stanhu, I have assigned this to you as you have been working on fixing broken members link when relative URL root paths are used and ZD ticket related to it (internal), but feel free to assign to someone else if that is the way to go, thanks!
- Stan Hu added regression:11.2 label
added regression:11.2 label
- Stan Hu added Manage [DEPRECATED] frontend labels
added Manage [DEPRECATED] frontend labels
It looks like bug with hard-coding the
/search
URL here: https://gitlab.com/gitlab-org/gitlab-ce/blob/8a116be4848720c41420c878c218b10ac7a3f182/app/assets/javascripts/search_autocomplete.js#L229-237I think this diff might fix the problem:
diff --git a/app/assets/javascripts/search_autocomplete.js b/app/assets/javascripts/search_autocomplete.js index 7bde4860973..ad4f5320ff8 100644 --- a/app/assets/javascripts/search_autocomplete.js +++ b/app/assets/javascripts/search_autocomplete.js @@ -226,7 +226,7 @@ export class SearchAutocomplete { icon, text: term, template: s__('SearchAutocomplete|in all GitLab'), - url: `/search?search=${term}`, + url: `${gon.relative_url_root}/search?search=${term}`, }); if (template) { @@ -234,7 +234,7 @@ export class SearchAutocomplete { icon, text: term, template, - url: `/search?search=${term}&project_id=${this.projectInputEl.val()}&group_id=${this.groupInputEl.val()}`, + url: `${gon.relative_url_root}/search?search=${term}&project_id=${this.projectInputEl.val()}&group_id=${this.groupInputEl.val()}`, }); } }
We really need some sort of utility function and linter to construct URLs because this isn't the first time this sort of thing has happened. Please stop constructing URLs without taking into account relative URLs.
/cc: @timzallmann, @dennis
A quick
git grep
turns up another possible offender:$ git grep "url: \`/" ide/stores/workers/files_decorator_worker.js: url: `/${projectId}/tree/${branchId}/-/${folderPath}/`, ide/stores/workers/files_decorator_worker.js: url: `/${projectId}/blob/${branchId}/-/${path}`, search_autocomplete.js: url: `/search?search=${term}`, search_autocomplete.js: url: `/search?search=${term}&project_id=${this.projectInputEl.val()}&group_id=${this.groupInputEl.val()}`,
- Stan Hu mentioned in merge request !22644 (merged)
mentioned in merge request !22644 (merged)
Since testing changes in JavaScript is hard with Omnibus (it requires recompiling assets, and it looks like we don't even ship
search_autocomplete.js
with the package) and setting up a GDK installation with a relative URL is a pain, I've just kicked off a full CE Omnibus build here: https://gitlab.com/gitlab-org/omnibus-gitlab/-/jobs/113610429Edited by Stan Hu- 🤖 GitLab Bot 🤖 added regression label
added regression label
- 🤖 GitLab Bot 🤖 mentioned in issue #53261 (closed)
mentioned in issue #53261 (closed)
- Maintainer
- Clement Ho closed via merge request !22644 (merged)
closed via merge request !22644 (merged)
- Clement Ho mentioned in commit e9814aae
mentioned in commit e9814aae
- Dennis Tang marked this issue as related to #53350 (moved)
marked this issue as related to #53350 (moved)
- Developer
@timzallmann sure thing, I've created https://gitlab.com/gitlab-org/gitlab-ce/issues/53350 to take care of this. I'll look at creating a Danger rule in order to check for absolute URLs, then recommend using
gon.relative_url_root
in order to remedy the situation. - 🤖 GitLab Bot 🤖 added devopsmanage label
added devopsmanage label
- Kazunori Kimura mentioned in issue gitlab#332018 (closed)
mentioned in issue gitlab#332018 (closed)