Skip to content

"Go to definition" broken for code host on non-standard port

Created by: rgalonso

  • Sourcegraph version: 3.17.3
  • Platform information: Docker

Steps to reproduce:

  1. Run self-hosted code host on non-standard port (i.e. not port 443)
  2. Configure code host and Sourcegraph to speak to one another
  3. Hover over code
  4. Click on "Go to definition"

Expected behavior:

Navigate to the page on the code host that contains the symbol definition. For example,

https://internal.mysite.com:7654/path/to/repo/blob/master/path/to/code#L123

Actual behavior:

Directed to page with address that is missing the port number.

https://internal.mysite.com/path/to/repo/blob/master/path/to/code#L123

Note the lack of a port number specification in the URL.

Specific use case

I've written the above bug description generically as it may apply to any code host running on a non-standard port, but here is my specific configuration. I am testing the Docker version of Sourcegraph with an internal self-hosted GitLab instance running on a port other than the standard 443. The GitLab version is 12.10.2 (Docker).

I've successfully configured the servers to talk to one another per the GitLab documentation. In Sourcegraph, I see and am able to search my repositories, and in GitLab I successfully get Sourcegraph-sourced popups when I hover over symbols. Clicking on "Find references" takes me to the appropriate page in the Sourcegraph instance as expected. However, clicking on "Go to definition" fails, because it tries to send me to the wrong page, as described above.

This could obviously be either on the GitLab or on the Sourcegraph side, but I think this may be an issue with Sourcegraph. I suspect this to be the case because I noticed that when I'm browsing the code for my repo within GitLab, the Sourcegraph URL is of the form

https://internal.mysite.com:7443/internal.mysite.com/path/to/repo@master/-/blob/path/to/code

not

https://internal.mysite.com:7443/internal.mysite.com:7654/path/to/repo@master/-/blob/path/to/code

(Note the addition of the port number.)

As the FQDN to my code host and the full path to the repo are in the Sourcegraph URL, but that URL lacks a reference to my code host's non-standard port number, I think this could be the source of the issue.