phacility/phabricator · warning · Exception

Expected "\r\n" or "--" after multipart data boundary.

Error message

Expected "\r\n" or "--" after multipart data boundary.

What it means

Thrown by 'bin/repository unpublish' when the operator declines the confirmation prompt. Unpublishing permanently deletes feed stories and notifications generated during repository import, so without '--force' the command asks 'Permanently unpublish "%s"?' and a 'no' answer aborts with this PhutilArgumentUsageException. Nothing was deleted when this is thrown.

Source

Thrown at src/aphront/multipartparser/AphrontMultipartParser.php:102

            $this->part = null;
            break;
          }

          if (!strncmp($this->buffer, "\r\n", 2)) {
            // This is "\r\n" after a boundary, so we're going to going to
            // read the headers for a part.
            $this->buffer = substr($this->buffer, 2);
            $this->state = 'header';

            // Create the object to hold the part we're about to read.
            $part = new AphrontMultipartPart();
            $this->parts[] = $part;
            $this->part = $part;
            break;
          }

          throw new Exception(
            pht('Expected "\r\n" or "--" after multipart data boundary.'));
        case 'header':
          // We've just parsed a boundary, followed by "\r\n". We are going
          // to read the headers for this part. They are in the form of HTTP
          // headers and terminated by "\r\n". The section is terminated by
          // a line with no header on it.

          if (strlen($this->buffer) < 2) {
            // We don't have enough data to find a "\r\n", so wait for more.
            $continue = false;
            break;
          }

          if (!strncmp("\r\n", $this->buffer, 2)) {
            // This line immediately began "\r\n", so we're done with parsing
            // headers. Start parsing the body.
            $this->buffer = substr($this->buffer, 2);
            $this->state = 'body';

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Re-run and answer 'y' once you are sure the import notifications should be removed.
  2. For automation, add '--force': 'bin/repository unpublish R12 --force' (optionally with '--dry-run' first to preview scope).
  3. Use '--dry-run' to review 'Will unpublish N commits' output before committing to the destructive run.

Example fix

# before (interactive, declined)
bin/repository unpublish R12

# afterin/repository unpublish R12 --dry-run   # preview
bin/repository unpublish R12 --force      # execute
Defensive patterns

Strategy: try-catch

Validate before calling

# Preview then execute explicitly:
bin/repository unpublish "$REPO" --dry-run
bin/repository unpublish "$REPO" --force

Try / catch

try {
  // exec of bin/repository unpublish
} catch (PhutilArgumentUsageException $ex) {
  if (preg_match('/aborted/', $ex->getMessage())) { /* operator cancelled; nothing deleted */ }
  throw $ex;
}

Prevention

When it happens

Trigger: Running 'bin/repository unpublish R12' without '--force' and answering 'n' at line 55; in non-interactive contexts the prompt reads EOF and counts as declined.

Common situations: Operators exploring what unpublish does; cron jobs calling unpublish without '--force' so stdin EOF aborts it; hesitation after reading the 'can not be undone' warning.

Related errors


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