Fix upload redirections when project has moved
Previously if a user attempted to click on a link to an attachment for a
renamed project (e.g. https://gitlab-org/gitlab-ce/uploads/123.png
),
Rails would redirect the user to an erroneous URL
(e.g. https://gitlab-org/gitlab-foss/uploads/123.png.png
). Notice the
redirect URL contains a redundant extension.
It turns out Rails 5 parses the extension of a route as the format (https://github.com/rails/rails/issues/28901#issuecomment-297747521), and the URL generator appends the format to the redirected route.
To fix this, we need to disable the format path parameter and explicitly
set the format to nil
. If we do not set the format to nil
, the URL
generator will append a query string (e.g ?format=png
), which would
still work but not necessary.
Closes #196232 (closed)
Merge request reports
Activity
changed milestone to %12.7
added Stuff that should Just Work devopsplan typebug labels
mentioned in issue #196232 (closed)
Reviewer roulette
Changes that require review have been detected! A merge request is normally reviewed by both a reviewer and a maintainer in its primary category (e.g. frontend or backend), and by a maintainer in all other categories.
To spread load more evenly across eligible reviewers, Danger has randomly picked a candidate for each review slot. Feel free to override this selection if you think someone else would be better-suited, or the chosen person is unavailable.
Once you've decided who will review this merge request, mention them as you normally would! Danger does not (yet?) automatically notify them for you.
Category Reviewer Maintainer backend Zamir Martins Filho ( @zmartins
)Nick Thomas ( @nick.thomas
)Generated by
DangerEdited by 🤖 GitLab Bot 🤖- Resolved by Stan Hu
added 1 commit
- ac09ef5c - Redirect to the canonical project upload path
added 1 commit
- ca2bc292 - Redirect to the canonical project upload path
I think this also affects group uploads since they can be redirected. These are the routes that have a
:filename
:GET /uploads/-/system/:model/:mounted_as/:id/:filename(.:format) uploads#show {:model=>/note|user|group|project/, :mounted_as=>/avatar|attachment/, :filename=>/[^\/]+/} GET /uploads/-/system/:model/:id/:secret/:filename(.:format) uploads#show {:model=>/personal_snippet|user/, :id=>/\d+/, :filename=>/[^\/]+/} GET /uploads/-/system/temp/:secret/:filename(.:format) uploads#show {:filename=>/[^\/]+/} appearance_upload GET /uploads/-/system/:model/:mounted_as/:id/:filename(.:format) uploads#show {:model=>/appearance/, :mounted_as=>/logo|header_logo|favicon/, :filename=>/.+/} GET /uploads/:namespace_id/:project_id/:secret/:filename(.:format) projects/uploads#show {:namespace_id=>/[a-zA-Z.0-9_\-]+/, :project_id=>/[a-zA-Z.0-9_\-]+/, :filename=>/[^\/]+/} GET /files/note/:id/:filename(.:format) redirect(301, uploads/note/attachment/%{id}/%{filename}) {:filename=>/[^\/]+/} show_group_uploads GET /groups/*group_id/-/uploads/:secret/:filename(.:format) groups/uploads#show {:filename=>/[^\/]+/} show_namespace_project_uploads GET /*namespace_id/:project_id/uploads/:secret/:filename(.:format) projects/uploads#show {:project_id=>/(?!((?i-mx:\-|badges|blame|blob|builds|commits|create|create_dir|edit|environments\/folders|files|find_file|gitlab\-lfs\/objects|info\/lfs\/objects|new|preview|raw|refs|tree|update|wikis))\/)(?-mix:(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*)(?-mix:(?<!\.git|\.atom)))/, :namespace_id=>/(?-mix:(?!((?i-mx:\-|\.well\-known|404\.html|422\.html|500\.html|502\.html|503\.html|abuse_reports|admin|api|apple\-touch\-icon\-precomposed\.png|apple\-touch\-icon\.png|assets|autocomplete|ci|dashboard|deploy\.html|explore|favicon\.ico|favicon\.png|files|groups|health_check|help|import|invites|jwt|login|notification_settings|oauth|profile|projects|public|robots\.txt|s|search|sent_notifications|slash\-command\-logo\.png|snippets|unsubscribes|uploads|users|v2))\/)(?-mix:(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])(?-mix:(?<!\.git|\.atom))))(?:\/(?!(?i-mx:\-|badges|blame|blob|builds|commits|create|create_dir|edit|environments\/folders|files|find_file|gitlab\-lfs\/objects|info\/lfs\/objects|new|preview|raw|refs|tree|update|wikis)\/)(?-mix:(?:[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_])(?-mix:(?<!\.git|\.atom))))*/, :filename=>/[^\/]+/}
added 14 commits
-
13ae2784...ee46dd70 - 13 commits from branch
master
- ab7c9d24 - Fix upload redirections when project has moved
-
13ae2784...ee46dd70 - 13 commits from branch
- Resolved by Stan Hu
- Resolved by Stan Hu
@stanhu Just a couple thoughts. Also thanks for the tests!!
Ready for maintainer review.
mentioned in issue #196396 (closed)
assigned to @ashmckenzie and unassigned @stanhu
added 10 commits
-
98440121...035fd458 - 8 commits from branch
master
- 6775f193 - Fix upload redirections when project has moved
- 8a8dccc8 - Deprecate legacy /uploads route
-
98440121...035fd458 - 8 commits from branch
I think 2 / 3 of the failures were due to #196398 (closed).
The
package-and-qa
job from pipeline https://gitlab.com/gitlab-org/gitlab/pipelines/108777856 triggered https://gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/pipelines/108785927 downstream.The
Trigger:qa-test
job from pipeline https://gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/pipelines/108785927 triggered https://gitlab.com/gitlab-org/gitlab-qa/pipelines/108790591 downstream.The
gitlab-qa
downstream pipeline passed. .
mentioned in commit 7465e2d1
mentioned in merge request !96323 (merged)