{"record":{"id":"768feaabcbad248c","repo":"phacility/phabricator","slug":"attempting-to-update-comment-content-state-but-re","errorCode":null,"errorMessage":"Attempting to update comment content state, but request has no content state.","messagePattern":"Attempting to update comment content state, but request has no content state\\.","errorType":"http","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/infrastructure/diff/PhabricatorInlineCommentController.php","lineNumber":567,"sourceCode":"      $inline = $inline->newInlineCommentObject();\n    }\n\n    return $inline;\n  }\n\n  private function hasContentState() {\n    $request = $this->getRequest();\n    return (bool)$request->getBool('hasContentState');\n  }\n\n  private function newRequestContentState($inline) {\n    $request = $this->getRequest();\n    return $inline->newContentStateFromRequest($request);\n  }\n\n  private function updateCommentContentState(PhabricatorInlineComment $inline) {\n    if (!$this->hasContentState()) {\n      throw new Exception(\n        pht(\n          'Attempting to update comment content state, but request has no '.\n          'content state.'));\n    }\n\n    $state = $this->newRequestContentState($inline);\n    $inline->setContentState($state);\n  }\n\n  private function saveComment(PhabricatorInlineComment $inline) {\n    $viewer = $this->getViewer();\n    $draft_engine = $this->newDraftEngine();\n\n    $inline->openTransaction();\n      $inline->save();\n\n      PhabricatorVersionedDraft::purgeDrafts(\n        $inline->getPHID(),","sourceCodeStart":549,"sourceCodeEnd":585,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/diff/PhabricatorInlineCommentController.php#L549-L585","documentation":"Thrown by updateCommentContentState() when it is asked to apply content state from a request whose `hasContentState` boolean flag is false/absent. Content state is the structured payload for comments with advanced storage (images, performed-actions, checklists): the client must declare `hasContentState=1` and send the state. Calling the update path without the declaration is a client/protocol mismatch, so the controller refuses rather than silently wiping the comment's state.","triggerScenarios":"POSTing an inline comment save/preview where `hasContentState` is omitted or 0 but the code path (subclass of PhabricatorInlineCommentController, e.g. transaction-based comment editing) calls updateCommentContentState(); custom clients or old UI code that never sends the flag; hand-built forms replicating the comment endpoint.","commonSituations":"Custom frontends or test harnesses posting to the inline endpoints without the modern comment form fields; browser extensions injecting forms; partial upgrades where cached JS no longer matches the server protocol.","solutions":["Send `hasContentState=1` together with the content state fields the client supports (the standard comment form does this)","If the comment genuinely has no advanced state, use the plain comment-save path instead of the content-state path","For custom clients, mirror the fields emitted by the upstream comment form (inspect a real submit in the network tab)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Client-side or in a custom controller: declare content state\n// whenever the payload includes state fields\n$has_state = ($images || $actions || $checklist);\nif ($has_state) {\n  $payload['hasContentState'] = 1;\n  $payload += $state_fields;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Replicate the upstream comment form's exact field set in custom clients; inspect a real browser submit","Never call the content-state update path for plain text-only comments"],"tags":["phabricator","inline-comments","code-review","protocol-mismatch","request-validation"],"backgroundTag":"missing-request-parameter","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}