{"record":{"id":"e25d874d86d3d699","repo":"phacility/phabricator","slug":"field-name-must-be-non-empty-e25d87","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/project/conduit/ProjectCreateConduitAPIMethod.php","lineNumber":49,"sourceCode":"  }\n\n  protected function defineReturnType() {\n    return 'dict';\n  }\n\n  protected function execute(ConduitAPIRequest $request) {\n    $user = $request->getUser();\n\n    $this->requireApplicationCapability(\n      ProjectCreateProjectsCapability::CAPABILITY,\n      $user);\n\n    $project = PhabricatorProject::initializeNewProject($user);\n    $type_name = PhabricatorProjectNameTransaction::TRANSACTIONTYPE;\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    $members = $request->getValue('members');\n    if ($members === null) {\n      $members = array();\n    }\n    $xactions = array();\n\n    $xactions[] = id(new PhabricatorProjectTransaction())\n      ->setTransactionType($type_name)\n      ->setNewValue($name);\n\n    if ($request->getValue('icon')) {\n      $xactions[] = id(new PhabricatorProjectTransaction())\n        ->setTransactionType(\n            PhabricatorProjectIconTransaction::TRANSACTIONTYPE)\n        ->setNewValue($request->getValue('icon'));\n    }","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/conduit/ProjectCreateConduitAPIMethod.php#L31-L67","documentation":"The project.create Conduit method requires a non-empty `name`; null or an empty string throws before any transaction is built. Caveat grounded in this revision: the guard reads !strlen(name) with a missing $ sigil, so on PHP 7 the empty-string half of the check never fires (the bare name constant evaluates to the string 'name', strlen 4), and on PHP 8 the expression itself fatals with an Error before this Exception can be thrown. Do not rely on the server-side check; validate the name in the caller.","triggerScenarios":"Calling project.create with `name` omitted, null, or an empty string. On PHP 8, any call reaching this line can also fatal on the bare-name constant regardless of the value passed.","commonSituations":"Provisioning scripts that derive project names from data which can be blank, and API clients with optional fields defaulting to ''.","solutions":["Send a non-empty, trimmed name in the request parameters.","Validate the name client-side before the call (see defense) so the request never reaches the guard.","If you maintain this checkout, restore the intended !strlen($name) guard."],"exampleFix":"// before\n$params = array('name' => $row['title']);\n// after\n$name = trim((string)$row['title']);\nif ($name === '') { continue; }\n$params = array('name' => $name);","handlingStrategy":"validation","validationCode":"$name = idx($params, 'name');\nif (!is_string($name) || trim($name) === '') {\n  // fix the source data or fail here; do not send the request\n  throw new Exception('project.create requires a non-empty name');\n}","typeGuard":"function is_nonempty_string($value) {\n  return is_string($value) && $value !== '';\n}","tryCatchPattern":"Conduit clients: catch the method's Exception on project.create, but prefer pre-validating; in this revision the server guard itself is buggy (!strlen(name) missing the $), so the client is the only reliable check.","preventionTips":["Trim and validate generated names before sending them to project.create.","Do not depend on the server-side empty check in this revision; the guard is missing a $ sigil.","Default optional client fields to a sensible non-empty name, not ''."],"tags":["phabricator","conduit","project-create","required-field","php-bug"],"backgroundTag":"api-required-field-missing","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}