phacility/phabricator · error · Exception

Unexpected "git upload-pack" initial protocol frame…

Error message

Unexpected "git upload-pack" initial protocol frame: expected "<hash> <name>\0<capabilities>\n", or "shallow <hash>\n", got "%s".

What it means

Parser guard in newProtocolRefMessage (reached from willReadBytes): the FIRST ref advertisement frame from 'git upload-pack' does not match the expected '<40-hex hash> <name>\0<capabilities>\n' or 'shallow <hash>\n' shape. It means the server's initial ref line — which carries capability negotiation — is malformed or unexpected, so ref parsing fails immediately.

Solutions

  1. Check what the upstream Git server actually sent (nonstandard ref or capability line)
  2. Verify Git protocol version compatibility between peers
  3. Inspect for proxies or rewrites mangling the first advertisement line
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/applications/diffusion/protocol/DiffusionGitUploadPackWireProtocol.php:227 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/473e44b825f87f4c. Report an issue: GitHub.

Appendix: source

Thrown at src/applications/diffusion/protocol/DiffusionGitUploadPackWireProtocol.php:227

      }

      $ok = preg_match(
        '('.
          '^'.
          '(?:'.
            '(?P<hash>[0-9a-f]{40}) (?P<name>[^\0\n]+)'.$capabilities_pattern.
            '|'.
            'shallow (?P<shallow>[0-9a-f]{40})'.
          ')'.
          '\n'.
          '\z'.
        ')',
        $bytes,
        $matches);

      if (!$ok) {
        if ($is_first) {
          throw new Exception(
            pht(
              'Unexpected "git upload-pack" initial protocol frame: expected '.
              '"<hash> <name>\0<capabilities>\n", or '.
              '"shallow <hash>\n", got "%s".',
              $bytes));
        } else {
          throw new Exception(
            pht(
              'Unexpected "git upload-pack" protocol frame: expected '.
              '"<hash> <name>\n", or "shallow <hash>\n", got "%s".',
              $bytes));
        }
      }

      if (isset($matches['shallow'])) {
        $name = null;
        $hash = $matches['shallow'];
        $is_shallow = true;

View on GitHub (pinned to 5720a38cfe)