{"record":{"id":"68912b106f474bcf","repo":"phacility/phabricator","slug":"field-slug-must-be-non-empty","errorCode":null,"errorMessage":"Field \"slug\" must be non-empty.","messagePattern":"Field \"slug\" must be non-empty\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/phriction/conduit/PhrictionCreateConduitAPIMethod.php","lineNumber":29,"sourceCode":"  }\n\n  protected function defineParamTypes() {\n    return array(\n      'slug'          => 'required string',\n      'title'         => 'required string',\n      'content'       => 'required string',\n      'description'   => 'optional string',\n    );\n  }\n\n  protected function defineReturnType() {\n    return 'nonempty dict';\n  }\n\n  protected function execute(ConduitAPIRequest $request) {\n    $slug = $request->getValue('slug');\n    if ($slug === null || !strlen($slug)) {\n      throw new Exception(pht('Field \"slug\" must be non-empty.'));\n    }\n\n    $doc = id(new PhrictionDocumentQuery())\n      ->setViewer($request->getUser())\n      ->withSlugs(array(PhabricatorSlug::normalize($slug)))\n      ->requireCapabilities(\n        array(\n          PhabricatorPolicyCapability::CAN_VIEW,\n          PhabricatorPolicyCapability::CAN_EDIT,\n        ))\n      ->executeOne();\n    if ($doc) {\n      throw new Exception(pht('Document already exists!'));\n    }\n\n    $doc = PhrictionDocument::initializeNewDocument(\n      $request->getUser(),\n      $slug);","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/phriction/conduit/PhrictionCreateConduitAPIMethod.php#L11-L47","documentation":"The phriction.create Conduit method requires the slug field (the wiki document path); execute() rejects a null or zero-length slug before any query runs. It is thrown as a plain Exception rather than a ConduitException, so Conduit clients see a generic error instead of a structured error code.","triggerScenarios":"Calling conduit method phriction.create with slug set to an empty string (presence checks pass, the strlen guard does not) or with slug explicitly null via a loose client.","commonSituations":"Client code builds the slug from a variable that is sometimes empty: an unset title, a blank form field, or slugification that produced nothing from punctuation-only or unicode input.","solutions":["Pass a non-empty slug in the conduit call parameters","Build the slug defensively and give it a fallback value before calling phriction.create","Normalize client-side with the same rules PhabricatorSlug::normalize() applies so the stored path matches expectations"],"exampleFix":"// before: slug built from a possibly-empty variable\n$client->callMethodSynchronous('phriction.create', array(\n  'slug' => $computed_slug,\n  'title' => $title,\n  'content' => $content,\n));\n\n// after: guarantee a non-empty slug before the call\nif ($computed_slug === null || !strlen($computed_slug)) {\n  $computed_slug = PhabricatorSlug::normalize($title);\n}\n$client->callMethodSynchronous('phriction.create', array(\n  'slug' => $computed_slug,\n  'title' => $title,\n  'content' => $content,\n));","handlingStrategy":"validation","validationCode":"$slug = (string)idx($params, 'slug', '');\nif ($slug === '') {\n  throw new InvalidArgumentException('phriction.create: slug must be non-empty');\n}\n$result = $client->callMethodSynchronous('phriction.create', $params);","typeGuard":null,"tryCatchPattern":"try {\n  $result = $client->callMethodSynchronous('phriction.create', $params);\n} catch (Exception $ex) {\n  if (strpos($ex->getMessage(), 'must be non-empty') !== false) {\n    // report as a caller parameter bug, not a server problem\n  }\n}","preventionTips":["Validate required conduit parameters at the client boundary before calling","Derive slugs from titles with a guaranteed fallback","Skip empty entries when batch-creating documents from external lists"],"tags":["phabricator","phriction","conduit","slug","input-validation"],"backgroundTag":"required-field-empty","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}