phacility/phabricator · error · Exception
Field "raw_diff" must be non-empty.
Error message
Field "raw_diff" must be non-empty.
What it means
differential.createrawdiff requires the 'diff' parameter containing raw unified-diff text; it is parsed by ArcanistDiffParser and turned into a DifferentialDiff. If the value is null or an empty string (strlen check), the method throws a plain Exception with 'Field "raw_diff" must be non-empty.' - note the message names 'raw_diff' although the actual parameter key is 'diff'.
Source
Thrown at src/applications/differential/conduit/DifferentialCreateRawDiffConduitAPIMethod.php:30
}
protected function defineParamTypes() {
return array(
'diff' => 'required string',
'repositoryPHID' => 'optional string',
'viewPolicy' => 'optional string',
);
}
protected function defineReturnType() {
return 'nonempty dict';
}
protected function execute(ConduitAPIRequest $request) {
$viewer = $request->getUser();
$raw_diff = $request->getValue('diff');
if ($raw_diff === null || !strlen($raw_diff)) {
throw new Exception(pht('Field "raw_diff" must be non-empty.'));
}
$repository_phid = $request->getValue('repositoryPHID');
if ($repository_phid) {
$repository = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
->withPHIDs(array($repository_phid))
->executeOne();
if (!$repository) {
throw new Exception(
pht('No such repository "%s"!', $repository_phid));
}
}
$parser = new ArcanistDiffParser();
$changes = $parser->parseDiff($raw_diff);
$diff = DifferentialDiff::newFromRawChanges($viewer, $changes);
View on GitHub (pinned to 5720a38cfe)
Solutions
- Send the unified diff text under the exact key 'diff' and verify it is non-empty before calling
- Check the upstream command (git diff / svn diff) actually produced output; fail the pipeline step if not
- Trim only trailing whitespace - an effectively whitespace-only diff is also useless
- Use the response's diffid for any follow-up create-revision call
Example fix
// before $params = array( 'raw_diff' => $diff_text, // wrong key: server expects 'diff' ); // after $params = array( 'diff' => $diff_text, // non-empty unified diff );
Defensive patterns
Strategy: validation
Validate before calling
if (!isset($params['diff']) || !is_string($params['diff'])
|| strlen(trim($params['diff'])) === 0) {
throw new InvalidArgumentException(
'createrawdiff requires non-empty diff text under key "diff"');
} Try / catch
try {
$result = $client->callMethodSynchronous('differential.createrawdiff', $params);
} catch (ConduitClientException $ex) {
if (strpos($ex->getMessage(), 'must be non-empty') !== false) {
// payload bug: the diff text is missing/empty - fix generation, do not retry
throw new RuntimeException('Empty raw diff', 0, $ex);
}
throw $ex;
} Prevention
- Use the exact parameter key 'diff', not 'raw_diff'
- Fail the pipeline when the diff-generating command yields empty output
- Check subprocess exit status before trusting diff output
When it happens
Trigger: Sending no 'diff' key, an empty string, or a value under a differently named key (for example literally 'raw_diff') because the error message's field name misled the caller.
Common situations: Scripts that read the diff from stdin or a file that turned out empty; parameter names copied from the exception text instead of the API spec; pipelines where the diff-producing step failed silently upstream.
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
- Field "changes" must be non-empty.
- ERR-BAD-DIFF
- ERR-NEED-DIFF
- ERR-NEED-FILE
- The raw diff you have submitted is too large to parse (it af
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/243eca8f2703ca0b.
Report an issue: GitHub.