{"record":{"id":"ebdd9577a1a2e472","repo":"phacility/phabricator","slug":"err-no-paste","errorCode":"ERR-NO-PASTE","errorMessage":"Paste may not be empty.","messagePattern":"Paste may not be empty\\.","errorType":"error_code","errorClass":"ConduitException","httpStatus":null,"severity":"error","filePath":"src/applications/paste/conduit/PasteCreateConduitAPIMethod.php","lineNumber":47,"sourceCode":"  }\n\n  protected function defineReturnType() {\n    return 'nonempty dict';\n  }\n\n  protected function defineErrorTypes() {\n    return array(\n      'ERR-NO-PASTE' => pht('Paste may not be empty.'),\n    );\n  }\n\n  protected function execute(ConduitAPIRequest $request) {\n    $content  = $request->getValue('content');\n    $title    = $request->getValue('title');\n    $language = $request->getValue('language');\n\n    if ($content === null || !strlen($content)) {\n      throw new ConduitException('ERR-NO-PASTE');\n    }\n\n    $title = nonempty($title, pht('Masterwork From Distant Lands'));\n    $language = nonempty($language, '');\n\n    $viewer = $request->getUser();\n\n    $paste = PhabricatorPaste::initializeNewPaste($viewer);\n\n    $xactions = array();\n\n    $xactions[] = id(new PhabricatorPasteTransaction())\n      ->setTransactionType(PhabricatorPasteContentTransaction::TRANSACTIONTYPE)\n      ->setNewValue($content);\n\n    $xactions[] = id(new PhabricatorPasteTransaction())\n      ->setTransactionType(PhabricatorPasteTitleTransaction::TRANSACTIONTYPE)\n      ->setNewValue($title);","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/paste/conduit/PasteCreateConduitAPIMethod.php#L29-L65","documentation":"Conduit error ERR-NO-PASTE, the only error type paste.create defines, returned when the 'content' parameter is null or an empty string (checked with strlen, so '0' is accepted). A paste must contain at least one byte of body text; the check happens before any transaction or policy logic runs.","triggerScenarios":"Calling the conduit method paste.create with content omitted, set to '', or carried by a variable that evaluated to null (failed file read, wrong array key, upstream command that produced no output).","commonSituations":"CLI/arcanist snippets piping command output that happens to be empty; reading a missing file into $content; JSON payload typos like 'contents' or 'text' that leave content unset; CI jobs that paste logs which are occasionally empty.","solutions":["Verify content is a non-empty string before calling paste.create.","If empty output is legitimate, skip the call or substitute a placeholder body such as '(empty output)'.","Fix the upstream source: check the file read or command execution that produced the content variable."],"exampleFix":"// before\n$result = $conduit->callMethod(\n  'paste.create',\n  array(\n    'content' => $content, // $content is null\n  ));\n\n// after\nif ($content === null || !strlen($content)) {\n  throw new Exception('Refusing to create an empty paste.');\n}\n$result = $conduit->callMethod(\n  'paste.create',\n  array(\n    'content' => $content,\n  ));","handlingStrategy":"validation","validationCode":"if (!is_string($content) || !strlen($content)) {\n  throw new Exception('Refusing to create an empty paste.');\n}\n$result = $conduit->callMethod(\n  'paste.create',\n  array(\n    'content' => $content,\n  ));","typeGuard":"function is_nonempty_paste_content($content) {\n  return is_string($content) && strlen($content) > 0;\n}","tryCatchPattern":"try {\n  $result = $conduit->callMethod('paste.create', $params);\n} catch (ConduitException $ex) {\n  if ($ex->getCode() === 'ERR-NO-PASTE') {\n    // fix the upstream content source and retry with non-empty body\n  }\n}","preventionTips":["Check content for null/empty before every paste.create call.","In piping scripts, handle legitimately empty output explicitly (skip or use a placeholder).","Verify file reads and upstream command exit status before pasting their output."],"tags":["phabricator","conduit","paste","validation","api"],"backgroundTag":"empty-request-parameter","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}