{"record":{"id":"5645e949a400398a","repo":"phacility/phabricator","slug":"field-name-must-be-non-empty","errorCode":null,"errorMessage":"Field \"name\" must be non-empty.","messagePattern":"Field \"name\" must be non-empty\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php","lineNumber":45,"sourceCode":"    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) {\n      $property = new DifferentialDiffProperty();\n      $property->setDiffID($diff_id);\n      $property->setName($name);\n    }\n    $property->setData($data);","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php#L27-L63","documentation":"name is the property key written to the diff property row (conventional examples are 'arc:lint', 'arc:unit', 'unit:result'). Null or zero-length names are rejected because a stored property needs a key.","triggerScenarios":"Passing name as null or '' — the key came from a variable that was never set, arguments were transposed, or the name was built by concatenation that produced an empty string.","commonSituations":"Copy-pasted call sites with a renamed constant; clients that send the value in name and the key in data; whitespace-trimmed names that reduced to empty.","solutions":["Pass a non-empty, stable property name such as 'arc:lint' or 'unit:result'.","Check strlen($name) before the call.","Derive names from a whitelist of the property keys your tooling reads."],"exampleFix":"// before\n$params['name'] = $prop_name; // $prop_name may be null\n\n// after\nif (!is_string($prop_name) || strlen($prop_name) === 0) {\n  throw new InvalidArgumentException('Property name must be non-empty.');\n}\n$params['name'] = $prop_name;","handlingStrategy":"validation","validationCode":"if (!is_string($name) || strlen($name) === 0) {\n  throw new InvalidArgumentException(\n    'Property name must be a non-empty string.');\n}\n$params['name'] = $name;","typeGuard":"function isPropertyName($value) {\n  return is_string($value) && strlen($value) > 0;\n}","tryCatchPattern":"try {\n  $client->callMethodSynchronous('differential.setdiffproperty', $params);\n} catch (ConduitClientException $ex) {\n  if (strpos($ex->getMessage(), '\"name\" must be non-empty') !== false) {\n    // caller bug: pass a real key such as 'arc:lint'\n  } else {\n    throw $ex;\n  }\n}","preventionTips":["Keep a whitelist of known property names ('arc:lint', 'arc:unit') and select from it.","Never build the name from unvalidated concatenation."],"tags":["phabricator","conduit","differential","diff-property","validation"],"backgroundTag":"empty-request-parameter","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}