phacility/phabricator · error · Exception

Expected %s or %s, got %s.

Error message

Expected %s or %s, got %s.

What it means

The same line-oriented state machine for svn ls --xml requires that after a completed <entry>, the next line is exactly '</list>' (finish) or '<entry' (next record); anything else throws (PhabricatorRepositorySvnCommitChangeParserWorker.php:698-716). The parser assumes a fixed, unindented serialization of the XML.

Source

Thrown at src/applications/repository/worker/commitchangeparser/PhabricatorRepositorySvnCommitChangeParserWorker.php:708

            if (!preg_match($pattern, $entry, $matches)) {
              throw new Exception(pht('Unable to parse entry!'));
            }
            $map[html_entity_decode($matches[2])] =
              $this->getFileTypeFromSVNKind($matches[1]);
            $mode = 'entry-or-end';
          } else {
            $entry[] = $line;
          }
          break;
        case 'entry-or-end':
          if ($line == '</list>') {
            $done = true;
            break 2;
          } else if ($line == '<entry') {
            $mode = 'entry';
            $entry = array();
          } else {
            throw new Exception(
              pht(
                'Expected %s or %s, got %s.',
                '</list>',
                '<entry',
                $line));
          }
          break;
        case 'xml':
          $expect = '/<?xml version="1.0".*?>/';
          if (!preg_match($expect, $line)) {
            throw new Exception(
              pht(
                "Expected '%s', got %s.",
                $expect,
                $line));
          }
          $mode = 'list';
          break;

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Run svn ls --xml manually as the daemon user and inspect the lines between entries
  2. Remove wrappers and silence svn warnings (trust the server cert, fix credentials) so only clean XML is emitted
  3. Pin svn to a version with the expected formatting, or patch the state machine upstream
Defensive patterns

Strategy: try-catch

Validate before calling

// Structural pre-flight: between entries only '</list>' and '<entry' may appear.
//   svn ls --xml <repo-url> | grep -n -v -e '</entry>' -e '<entry' -e '</list>' -e '<lists>' -e '<?xml'
// Any surviving line will break the parser.

Try / catch

try {
  $map = $this->parseSVNListXML($file_path);
} catch (Exception $ex) {
  // Unexpected line between entries: almost always svn warnings or new
  // formatting. Silence warnings (cert trust, credentials) or pin svn.
  phlog(file_get_contents($file_path));
  throw $ex;
}

Prevention

When it happens

Trigger: svn emitting XML with indentation, blank lines, comments, or reformatted structure between entries; warning text from svn (certificate, auth, deprecation notices) interleaved into stdout mid-stream.

Common situations: svn client/server upgrades changing output formatting; svn warnings printed to stdout; wrapper scripts or proxies altering the stream.

Related errors


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