{"record":{"id":"d39aa1d15c38cf97","repo":"phacility/phabricator","slug":"field-diff-id-must-be-non-null","errorCode":null,"errorMessage":"Field \"diff_id\" must be non-null.","messagePattern":"Field \"diff_id\" must be non-null\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php","lineNumber":40,"sourceCode":"  protected function defineReturnType() {\n    return 'void';\n  }\n\n  protected function defineErrorTypes() {\n    return array(\n      'ERR_NOT_FOUND' => pht('Diff was not found.'),\n    );\n  }\n\n  protected function execute(ConduitAPIRequest $request) {\n    $data = $request->getValue('data');\n    if ($data === null || !strlen($data)) {\n      throw new Exception(pht('Field \"data\" must be non-empty.'));\n    }\n\n    $diff_id = $request->getValue('diff_id');\n    if ($diff_id === null) {\n      throw new Exception(pht('Field \"diff_id\" must be non-null.'));\n    }\n\n    $name = $request->getValue('name');\n    if ($name === null || !strlen($name)) {\n      throw new Exception(pht('Field \"name\" must be non-empty.'));\n    }\n\n    $data = json_decode($data, true);\n\n    self::updateDiffProperty($diff_id, $name, $data);\n  }\n\n  private static function updateDiffProperty($diff_id, $name, $data) {\n    $property = id(new DifferentialDiffProperty())->loadOneWhere(\n      'diffID = %d AND name = %s',\n      $diff_id,\n      $name);\n    if (!$property) {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php#L22-L58","documentation":"diff_id selects which diff the property attaches to, and the method only checks it against null. Omitting diff_id or explicitly sending null throws immediately, before the name validation runs.","triggerScenarios":"Requests that omit diff_id because the client builds parameters conditionally and the diff id variable was never set, or that send null explicitly.","commonSituations":"Scripts that call differential.setdiffproperty before differential.creatediff returned an ID; parameter-name mismatches such as 'diffID' vs 'diff_id'; null defaults left in place.","solutions":["Always pass the integer diff ID returned by differential.creatediff (or read from the diff object).","Validate that diff_id is a positive integer before calling.","Note the server only rejects null here — '0' passes this check but fails later with ERR_NOT_FOUND, so validate yourself."],"exampleFix":"// before\n$params = array(\n  'name' => 'arc:lint',\n  'data' => $json,\n  // diff_id never set\n);\n\n// after\nif ($diff_id === null || $diff_id <= 0) {\n  throw new InvalidArgumentException('diff_id must be a positive integer.');\n}\n$params = array(\n  'diff_id' => $diff_id,\n  'name' => 'arc:lint',\n  'data' => $json,\n);","handlingStrategy":"validation","validationCode":"if ($diff_id === null || !is_int($diff_id) || $diff_id <= 0) {\n  throw new InvalidArgumentException('diff_id must be a positive integer.');\n}\n$params['diff_id'] = $diff_id;","typeGuard":"function isDiffID($value) {\n  return is_int($value) && $value > 0;\n}","tryCatchPattern":"try {\n  $client->callMethodSynchronous('differential.setdiffproperty', $params);\n} catch (ConduitClientException $ex) {\n  if (strpos($ex->getMessage(), '\"diff_id\" must be non-null') !== false) {\n    // caller bug: set the diff id from the creatediff result\n  } else {\n    throw $ex;\n  }\n}","preventionTips":["Use the diff id returned by differential.creatediff.","Validate all three required parameters (diff_id, name, data) in one guard before calling.","The server only rejects null here, so check the positive-integer range yourself."],"tags":["phabricator","conduit","differential","diff-property","validation"],"backgroundTag":"missing-request-parameter","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}