phacility/phabricator · error · ConduitException

ERR-NEED-FILE

ERR-NEED-FILE

Error message

ERR-NEED-FILE

What it means

Thrown by differential.createinline when the filePath parameter is empty. After resolving the revision and diff, the method loads the diff's changesets and matches them against filePath; an empty value can never match, so it fails fast with ConduitException('ERR-NEED-FILE').

Source

Thrown at src/applications/differential/conduit/DifferentialCreateInlineConduitAPIMethod.php:83

        if (!$diff || $diff->getRevisionID() != $rid) {
          throw new ConduitException('ERR-BAD-DIFF');
        }
      }
    } else if ($did) {
      // Given only a diff, find the parent revision.
      $diff = id(new DifferentialDiff())->load($did);
      if (!$diff) {
        throw new ConduitException('ERR-BAD-DIFF');
      }
      $rid = $diff->getRevisionID();
    } else {
      // Given neither, bail.
      throw new ConduitException('ERR-NEED-DIFF');
    }

    $file = $request->getValue('filePath');
    if (!$file) {
      throw new ConduitException('ERR-NEED-FILE');
    }
    $changes = id(new DifferentialChangeset())->loadAllWhere(
      'diffID = %d',
      $did);
    $cid = null;
    foreach ($changes as $id => $change) {
      if ($file == $change->getFilename()) {
        $cid = $id;
      }
    }
    if ($cid == null) {
      throw new ConduitException('ERR-BAD-FILE');
    }

    $inline = id(new DifferentialInlineComment())
      ->setRevisionID($rid)
      ->setChangesetID($cid)
      ->setAuthorPHID($request->getUser()->getPHID())

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Always send a non-empty filePath string
  2. Skip comment records with no file before making the call
  3. For general (non-inline) feedback, use differential.createcomment with a message instead of an inline with an empty path

Example fix

// before
$params = array(
  'revisionID' => 789,
  'filePath' => '',
  'content' => 'General note.',
);

// after
// no file: post a normal comment instead
$client->callMethodSynchronous('differential.createcomment', array(
  'revision_id' => 789,
  'message' => 'General note.',
));
Defensive patterns

Strategy: validation

Validate before calling

if (!isset($params['filePath']) || !strlen(trim((string)$params['filePath']))) {
  // no file: downgrade to a plain comment or skip
  return postPlainComment($params);
}

Prevention

When it happens

Trigger: Calling differential.createinline with filePath missing, null, or an empty string - typically when the caller's path variable was never set for a whole-file comment.

Common situations: Automated commenters generating one record per finding where some findings have no file; CSV/config rows with empty path columns; refactors that renamed the parameter key.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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