Skip to content

"Open in Web IDE" fails to load files if clicked while browsing a repository at a specific commit

Summary

When viewing a commit and going directly to the repository page, the id of the commit is retained in the url and gets set as the branch. As there is no branch with that name an error occurs when trying to edit said branch.

Steps to reproduce

  1. View a source code file at a specific commit (not a branch). You can get here by any of the following:
    • Browsing the repository starting from a commit.
      1. Open any commit.
        image

      2. Click repository on the left menu. The id of the commit is retained in the url and gets set as the branch.
        image

    • Directly configuring the source code viewer to show you a file at a certain revision, by either:
      • Selecting a commit from the dropdown.
      • Getting a permalink to a file by pressing the y keyboard shortcut.
    • Viewing a file in an MR:
      1. Openi the Changes tab.
      2. Select the three-dots menu on a file.
      3. Select "View file @ " (the first option).
        Click to expand Screenshot_2023-05-19_at_12.36.06_PM
  2. Select "Open in Web IDE" and try to edit a file. An error message is shown. image

What is the current bug behavior?

When going from a commit to repository page the branch is set to id of that commit, and the IDE can't load files for editing.

What is the expected correct behavior?

When going from a commit to repository page the branch is set correctly and the IDE can be used to edit the file.

Reproduction steps

  1. Visit https://gitlab.com/gitlab-org/gitlab/-/tree/b69b567e95393f73d900415d43b17c7dd126a8da
  2. Click on WebIDE button
  3. Select gitlab file on the left

image

Edited by Connor Gilbert