phacility/phabricator · error · PhabricatorEditorURIParserException

Editor pattern "%s" is invalid: the pattern must begin with

Error message

Editor pattern "%s" is invalid: the pattern must begin with a valid editor protocol, but the protocol "%s://" is not allowed.

What it means

Even with a syntactically valid protocol, the editor pattern's scheme must be present in the `uri.allowed-editor-protocols` cluster config, which defaults to schemes like mvim, vim, emacs, texmate, and subl. The check empty($allowed_protocols[$editor_protocol]) throws PhabricatorEditorURIParserException, mirroring Phabricator's general policy of whitelisting URI protocols for anything Phabricator renders or links to.

Source

Thrown at src/infrastructure/editor/PhabricatorEditorURIEngine.php:225

      }
    }

    $uri = new PhutilURI($first_literal);
    $editor_protocol = $uri->getProtocol();

    if (!$editor_protocol) {
      throw new PhabricatorEditorURIParserException(
        pht(
          'Editor pattern "%s" is invalid: the pattern must begin with '.
          'a valid editor protocol, but does not begin with a recognized '.
          'protocol string.',
          $raw_pattern));
    }

    $allowed_key = 'uri.allowed-editor-protocols';
    $allowed_protocols = PhabricatorEnv::getEnvConfig($allowed_key);
    if (empty($allowed_protocols[$editor_protocol])) {
      throw new PhabricatorEditorURIParserException(
        pht(
          'Editor pattern "%s" is invalid: the pattern must begin with '.
          'a valid editor protocol, but the protocol "%s://" is not allowed.',
          $raw_pattern,
          $editor_protocol));
    }

    return $tokens;
  }

  private function newTokensWithVariables(array $tokens, array $variables) {
    // Replace all "variable" tokens that we have replacements for with
    // the literal value.
    foreach ($tokens as $key => $token) {
      $type = $token['type'];

      if ($type == 'variable') {
        $variable = $token['value'];

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Extend the whitelist: `./bin/config set uri.allowed-editor-protocols '{"vscode": true, "mvim": true, "vim": true, "emacs": true, "texmate": true, "subl": true}'` (merge with existing values, note the set replaces the map).
  2. Alternatively change the pattern to use one of the already-allowed protocols.
  3. After editing config, have affected users reload - patterns are re-parsed on next use, so no restart beyond standard config cache is needed.

Example fix

// before: pattern uses a scheme missing from the whitelist
vscode://file/%f:%l   // throws: "vscode" not allowed

// after: allow the scheme in config
$ ./bin/config set uri.allowed-editor-protocols '{"vscode":true,"mvim":true,"vim":true,"emacs":true,"texmate":true,"subl":true}'
Defensive patterns

Strategy: validation

Validate before calling

$pattern = 'vscode://file/%f:%l';
$proto = (new PhutilURI(head((array_filter(
  PhabricatorEditorURIEngine::newPatternTokens($pattern),
  function ($t) { return $t['type'] === 'literal'; })))[0]['value']))
  ->getProtocol();
$allowed = PhabricatorEnv::getEnvConfig('uri.allowed-editor-protocols');
if (empty($allowed[$proto])) {
  // whitelist the scheme first, or pick an allowed one
}

Try / catch

try {
  PhabricatorEditorURIEngine::newFromEnvPattern()->newURIForLine($path, $line);
} catch (PhabricatorEditorURIParserException $ex) {
  // protocol not whitelisted: fall back to rendering a plain file/line label
  return phutil_tag('code', array(), $path.':'.$line);
}

Prevention

When it happens

Trigger: Setting `editor` to a pattern using a scheme not in the whitelist, e.g. 'vscode://file/%f:%l' or 'idea://open?file=%f' while `uri.allowed-editor-protocols` does not include 'vscode'/'idea'; the engine resolves the protocol then fails the config lookup.

Common situations: Switching teams to an editor whose handler scheme (vscode, atom, idea, stormlink) postdates the installed Phabricator defaults; locking down protocols centrally while users keep old preferences; custom in-house editor protocols.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/ccd5fa9854a903f9. Report an issue: GitHub.