Skip to content

fix: default to `localhost` for local registry prefix

Warren Gifford requested to merge default-local-registry-prefix into master

Created by: chrismwendt

Previously, publishing an extension to an instance that didn't have appURL set would result in an error:

$ src -config=/Users/chrismwendt/src-config.dev.tmp.json extensions publish
...

GraphQL errors:
[
  {
    "message": "unable to publish remote extension \"/alice/sourcegraph-hello-world\" (publish it directly to the registry on \"\")",
    "path": [
      "extensionRegistry",
      "publishExtension"
    ]
  }
]

This was happening because the extension ID prefix is generated from appURL's hostname, which was the empty string "", resulting in extension IDs of the form /publisher/name, which is invalid. Extension IDs are only valid if they have 2 or 3 path components.

The solution is to default to localhost for local extension ID prefixes when appURL is not set. This fixes both publishing and viewing extensions in the registry UI (viewing used to panic).

Fixes https://github.com/sourcegraph/enterprise/issues/13520

This PR does not need to update the CHANGELOG because this isn't released

Merge request reports

Loading