{"record":{"id":"243eca8f2703ca0b","repo":"phacility/phabricator","slug":"field-raw-diff-must-be-non-empty","errorCode":null,"errorMessage":"Field \"raw_diff\" must be non-empty.","messagePattern":"Field \"raw_diff\" must be non-empty\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/differential/conduit/DifferentialCreateRawDiffConduitAPIMethod.php","lineNumber":30,"sourceCode":"  }\n\n  protected function defineParamTypes() {\n    return array(\n      'diff' => 'required string',\n      'repositoryPHID' => 'optional string',\n      'viewPolicy' => 'optional string',\n    );\n  }\n\n  protected function defineReturnType() {\n    return 'nonempty dict';\n  }\n\n  protected function execute(ConduitAPIRequest $request) {\n    $viewer = $request->getUser();\n    $raw_diff = $request->getValue('diff');\n    if ($raw_diff === null || !strlen($raw_diff)) {\n      throw new Exception(pht('Field \"raw_diff\" must be non-empty.'));\n    }\n\n    $repository_phid = $request->getValue('repositoryPHID');\n    if ($repository_phid) {\n      $repository = id(new PhabricatorRepositoryQuery())\n        ->setViewer($viewer)\n        ->withPHIDs(array($repository_phid))\n        ->executeOne();\n      if (!$repository) {\n        throw new Exception(\n          pht('No such repository \"%s\"!', $repository_phid));\n      }\n    }\n\n    $parser = new ArcanistDiffParser();\n    $changes = $parser->parseDiff($raw_diff);\n    $diff = DifferentialDiff::newFromRawChanges($viewer, $changes);\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialCreateRawDiffConduitAPIMethod.php#L12-L48","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n$params = array(\n  'raw_diff' => $diff_text, // wrong key: server expects 'diff'\n);\n\n// after\n$params = array(\n  'diff' => $diff_text, // non-empty unified diff\n);","handlingStrategy":"validation","validationCode":"if (!isset($params['diff']) || !is_string($params['diff'])\n    || strlen(trim($params['diff'])) === 0) {\n  throw new InvalidArgumentException(\n    'createrawdiff requires non-empty diff text under key \"diff\"');\n}","typeGuard":null,"tryCatchPattern":"try {\n  $result = $client->callMethodSynchronous('differential.createrawdiff', $params);\n} catch (ConduitClientException $ex) {\n  if (strpos($ex->getMessage(), 'must be non-empty') !== false) {\n    // payload bug: the diff text is missing/empty - fix generation, do not retry\n    throw new RuntimeException('Empty raw diff', 0, $ex);\n  }\n  throw $ex;\n}","preventionTips":["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"],"tags":["phabricator","conduit","differential","diff","missing-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}