Skip to content

Fix route snippet helpers

What does this MR do?

In !20478 (merged) we refactored snippets' routes to have a single place to check if the snippet was a ProjectSnippet or a PersonalSnippet and call the proper route. Besides, in preparation for other features, we added a way to add query params automatically to all snippet routes.

Nevertheless, it seems to fail in production (#38068 (closed)). It does not fail in development or test environments. I've tried to setup the production environment caching the classes and avoid reloading but I can't make it fail.

I think the bug might be for either of these two reasons:

  • In several routes we check snippet.is_a?(Projectsnippet). Maybe, for some unknown reason, in production the snippet class is Snippet and that's why it returns the personal snippet route
  • The route helper does not overwrite the existing one and we're calling the default generated route, which doesn't check the type of snippet and, therefore, it returns the personal snippet route as well.

I can't check the location of the method in production, so I'm trying to see if it's the first reason (which is simpler).

If this fix doesn't work, I'll revert this MR merge commit and also 1e8eee9f.

Refs #38068 (closed)

Does this MR meet the acceptance criteria?

Conformity

Merge request reports