Skip to content

Add support for redirects to go-get middleware

Vasilii Iakliushin requested to merge 467850_go_middleware_follow_redirects into master

What does this MR do and why?

Contributes to #467850 (closed)

Problem

The new strict version of go-get validation !156860 (merged) returns 404 page when the requested project is not found.

That breaks the support for redirected routes.

For example, a project like gitlab.com/namespace/project can be accessed via go get.

go get gitlab.com/namespace/project

Before the restriction we would return a 200 response code, go will follow redirects and process the downloading the package.

The new strict version, will return 404 response code and stop go get execution.

Solution

Add a verification for redirect routes. When user requests the old path, go get response will be 200 and include a link to the new project path.

How to set up and validate locally

  1. Enable feature flag Feature.enable(:not_found_response_for_go_get)
  2. Create a new project
  3. Visit URL like http://gdk.test:3000/<namespace>/<project>?go-get=1
  4. It should respond with HTTP 200
  5. Go to Settings -> General -> Advanced -> Change path
  6. Set a new path for the project

Both URL should return HTTP 200:

  • http://gdk.test:3000/<namespace>/<project>?go-get=1 - HTTP 200
  • http://gdk.test:3000/<namespace>/<new_project_path>?go-get=1 - HTTP 200

Before the fix:

  • http://gdk.test:3000/<namespace>/<project>?go-get=1 - HTTP 404 (cannot access old path)
  • http://gdk.test:3000/<namespace>/<new_project_path>?go-get=1 - HTTP 200
Edited by Vasilii Iakliushin

Merge request reports

Loading