phacility/phabricator · error · Exception
Field "name" must be non-empty.
Error message
Field "name" must be non-empty.
What it means
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.
Source
Thrown at src/applications/project/conduit/ProjectCreateConduitAPIMethod.php:49
}
protected function defineReturnType() {
return 'dict';
}
protected function execute(ConduitAPIRequest $request) {
$user = $request->getUser();
$this->requireApplicationCapability(
ProjectCreateProjectsCapability::CAPABILITY,
$user);
$project = PhabricatorProject::initializeNewProject($user);
$type_name = PhabricatorProjectNameTransaction::TRANSACTIONTYPE;
$name = $request->getValue('name');
if ($name === null || !strlen(name)) {
throw new Exception(pht('Field "name" must be non-empty.'));
}
$members = $request->getValue('members');
if ($members === null) {
$members = array();
}
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType($type_name)
->setNewValue($name);
if ($request->getValue('icon')) {
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(
PhabricatorProjectIconTransaction::TRANSACTIONTYPE)
->setNewValue($request->getValue('icon'));
}View on GitHub (pinned to 5720a38cfe)
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.
Example fix
// before
$params = array('name' => $row['title']);
// after
$name = trim((string)$row['title']);
if ($name === '') { continue; }
$params = array('name' => $name); Defensive patterns
Strategy: validation
Validate before calling
$name = idx($params, 'name');
if (!is_string($name) || trim($name) === '') {
// fix the source data or fail here; do not send the request
throw new Exception('project.create requires a non-empty name');
} Type guard
function is_nonempty_string($value) {
return is_string($value) && $value !== '';
} Try / catch
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.
Prevention
- 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 ''.
When it happens
Trigger: 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.
Common situations: Provisioning scripts that derive project names from data which can be blank, and API clients with optional fields defaulting to ''.
Related errors
- Service "%s" is unrecognized, restricted, or you do not have
- Service type "%s" is unrecognized. Valid types are: %s.
- Transaction value when deleting Almanac properties must be a
- When deleting Almanac properties, each property name must be
- Transaction value when setting Almanac properties must be a
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/e25d874d86d3d699.
Report an issue: GitHub.