Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Wrong URL when opening file on Sourcegraph web using the JetBrains plugin #49510

Open
taras-yemets opened this issue Mar 16, 2023 · 6 comments
Open
Labels
bug An error, flaw or fault that produces an incorrect or unexpected result, or behavior. team/code-search Issues owned by the code search team

Comments

@taras-yemets
Copy link
Contributor

taras-yemets commented Mar 16, 2023

Reported by https://github.com/sourcegraph/accounts/issues/6716

    • Platform information: Sourcegraph for JetBrains 2.1.2

Steps to reproduce:

  1. Open the file from the Perforce repo in JetBrains IDE.
  2. Ensure Sourcegraph plugin is installed and configured (README).
  3. Open Sourcegraph plugin context menu and click "Open selection in Sourcegraph web".

More context can be found in this Slack thread.

Expected behavior:

The file is opened on a connected Sourcegraph instance with proper query params (revision, line, etc.).

Actual behavior:

The link navigates to the file not found page on a connected Sourcegraph instance.

If you would like immediate help on this, please email [email protected] (you can still create the issue, but there are no SLAs on issues like there are for support requests).

@taras-yemets taras-yemets added bug An error, flaw or fault that produces an incorrect or unexpected result, or behavior. team/code-exploration Issues owned by the Code Exploration team labels Mar 16, 2023
@peterguy
Copy link
Contributor

peterguy commented Apr 6, 2023

Does this have any overlap with #42294?

@peterguy peterguy added the first-class-perforce Issues associated with make Perforce a first class code host label Apr 6, 2023
@johnwesonga johnwesonga added the EE/paper cuts customer issues that will be worked on as part of EE rotation label May 15, 2023
@vdavid
Copy link
Contributor

vdavid commented May 18, 2023

@vdavid
Copy link
Contributor

vdavid commented May 18, 2023

@peterguy: they have no overlap.

  • https://github.com/sourcegraph/sourcegraph/issues/42294, is about the situation when one uses the "Find with Sourcegraph" dialog (the one that opens for Option+S), finds a file, then chooses to open the file for editing. In this case, we try to match the file found on Sourcegraph (which only exists in memory) to a local file (which exists on the disk). The benefit of doing this successfully is, of course, that you can make changes to the file and eventually commit it. This is what doesn't always work with Perforce now.
  • This current issue is for the case when you have a local file open in your IDE, and you want to open this file on Sourcegraph web, typically for sharing the link with a colleague. This is another thing that doesn't work well with some Perforce setups.

@taras-yemets
Copy link
Contributor Author

@vdavid, @philipp-spiess, and I looked into this issue. Here are some findings.

The repo on the user’s system is coming from a GHE code host (is a Git repository), but that code is cloned over from Perforce using some proprietary tooling. However, Sourcegraph instance only has Perforce code cloned via p4-fusion (original message).
Thus the version control system defined by getRemoteRepoURL is VCSType.GIT and is handled respectively. This remote repo URL is used to build an editor file URL. It is later used redirected according to the logic defined in editor.go.
As the Sourcegraph instance knows nothing about this Git repo (it knows only about the Perforce one the Git repo has been cloned from), the user is expectedly navigated to the repo not found page (Git repo doesn't exist on the Sourcegraph instance).

There is a possibility to configure remote URL replacements. Still, it's not going to work with the current logic of opening/copying Sourcegraph URL from IDE (building the editor URL in the IDE plugin and then opening file redirect) as RepoSourceCloneURLToRepoName function currently doesn't support Perforce code host.

Possible solutions we could think of:

  1. Add another plugin configuration field to the JetBrains plugin defining repo name configurations. If the project opened in IDE matches the pattern from this new field value, we build the actual link to a file on Sourcegraph instance (e.g. similar to toBlobAbsoluteURL) on the plugin side (but not the editor file URL). In this way we can skip the mentioned open file redirect logic which currently doesn't support Perforce. Keep the repo remote URL replacements logic as it is.
  2. Do not add a new config field and use the existing logic for repo remote URL replacements. Build the actual link to a file on Sourcegraph instance (e.g. similar to toBlobAbsoluteURL) on the plugin side. In this case, we do not depend on openFileRedirect logic.
  3. Do not change the plugin code, but add Perforce support to RepoSourceCloneURLToRepoName.

@taylorsperry
Copy link
Contributor

@taras-yemets Do you know if this is still an issue? Sounds like it's related to the "search" component of the JB Search + Cody plugin.

@taras-yemets
Copy link
Contributor Author

taras-yemets commented Jan 9, 2024

@taras-yemets Do you know if this is still an issue? Sounds like it's related to the "search" component of the JB Search + Cody plugin.

@taylorsperry, yes, this is JB Search + Cody plugin issue and it's still relevant.

@fkling fkling added team/code-search Issues owned by the code search team imported Label for marking issues that have been imported from another team and removed team/code-exploration Issues owned by the Code Exploration team labels Feb 22, 2024
@camdencheek camdencheek removed first-class-perforce Issues associated with make Perforce a first class code host imported Label for marking issues that have been imported from another team EE/paper cuts customer issues that will be worked on as part of EE rotation labels May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug An error, flaw or fault that produces an incorrect or unexpected result, or behavior. team/code-search Issues owned by the code search team
Projects
None yet
Development

No branches or pull requests

7 participants