phacility/phabricator · error · Exception

The remote URI has leading or trailing whitespace.

Error message

The remote URI has leading or trailing whitespace.

What it means

Validation in PhabricatorRepository::assertValidRemoteURI: the remote URI has leading or trailing whitespace (trim differs from the raw string). Whitespace-padded URIs are rejected before parsing the protocol.

Solutions

  1. Strip leading and trailing whitespace from the remote URI before saving.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/applications/repository/storage/PhabricatorRepository.php:1641 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at src/applications/repository/storage/PhabricatorRepository.php:1641

                VALUES(messageCount)),
            statusCode = VALUES(statusCode),
            parameters = VALUES(parameters),
            epoch = VALUES(epoch)',
        $table_name,
        $this->getID(),
        $status_type,
        $status_code,
        json_encode($parameters),
        time(),
        1);
    }

    return $this;
  }

  public static function assertValidRemoteURI($uri) {
    if (trim($uri) != $uri) {
      throw new Exception(
        pht('The remote URI has leading or trailing whitespace.'));
    }

    $uri_object = new PhutilURI($uri);
    $protocol = $uri_object->getProtocol();

    // Catch confusion between Git/SCP-style URIs and normal URIs. See T3619
    // for discussion. This is usually a user adding "ssh://" to an implicit
    // SSH Git URI.
    if ($protocol == 'ssh') {
      if (preg_match('(^[^:@]+://[^/:]+:[^\d])', $uri)) {
        throw new Exception(
          pht(
            "The remote URI is not formatted correctly. Remote URIs ".
            "with an explicit protocol should be in the form ".
            "'%s', not '%s'. The '%s' syntax is only valid in SCP-style URIs.",
            'proto://domain/path',
            'proto://domain:/path',

View on GitHub (pinned to 5720a38cfe)