{"record":{"id":"0804be848219c487","repo":"phacility/phabricator","slug":"you-must-select-at-least-one-project-tag-to-add","errorCode":null,"errorMessage":"You must select at least one project tag to add.","messagePattern":"You must select at least one project tag to add\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/project/trigger/PhabricatorProjectTriggerAddProjectsRule.php","lineNumber":28,"sourceCode":"  }\n\n  protected function getValueForEditorField() {\n    return $this->getDatasource()->getWireTokens($this->getValue());\n  }\n\n  protected function assertValidRuleRecordFormat($value) {\n    if (!is_array($value)) {\n      throw new Exception(\n        pht(\n          'Add project rule value should be a list, but is not '.\n          '(value is \"%s\").',\n          phutil_describe_type($value)));\n    }\n  }\n\n  protected function assertValidRuleRecordValue($value) {\n    if (!$value) {\n      throw new Exception(\n        pht(\n          'You must select at least one project tag to add.'));\n    }\n  }\n\n  protected function newDropTransactions($object, $value) {\n    $project_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;\n\n    $xaction = $object->getApplicationTransactionTemplate()\n      ->setTransactionType(PhabricatorTransactions::TYPE_EDGE)\n      ->setMetadataValue('edge:type', $project_edge_type)\n      ->setNewValue(\n        array(\n          '+' => array_fuse($value),\n        ));\n\n    return array($xaction);\n  }","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/trigger/PhabricatorProjectTriggerAddProjectsRule.php#L10-L46","documentation":"Thrown by assertValidRuleRecordValue() for the 'task.projects.add' rule when the value list is empty. Unlike the format check, this runs at trigger-editor save time via getRuleRecordValueValidationException(), so it is validation of user input: an 'Add project tags' rule was configured without selecting any project.","triggerScenarios":"In the trigger editor, add an 'Add project tags' rule, leave the tokenizer empty, and save. Also fires when a stored record has value [] and the UI re-validates or applies the trigger.","commonSituations":"A user picks the rule type but forgets to choose projects; a tokenizer failed to load its datasource so the field silently stayed empty; an API/script client posted an empty value list to the trigger editor.","solutions":["Open the trigger in the editor and select at least one project tag in the 'Add project tags' field, then save.","If the tokenizer never loads options, check that the project datasource is reachable and the viewer can see projects (policy issue).","If editing via Conduit/scripts, ensure the posted value is a non-empty array of project PHIDs."],"exampleFix":"// before\n$value = array();\n\n// after\n$value = array('PHID-PROJ-xyz');","handlingStrategy":"validation","validationCode":"// Before saving the trigger in custom client code:\nif (!$value) {\n  throw new Exception('Select at least one project tag to add.');\n}","typeGuard":"function isNonEmptyProjectList($value) {\n  return is_array($value) && count($value) > 0;\n}","tryCatchPattern":"$validation = $rule->getRuleRecordValueValidationException();\nif ($validation) {\n  // surface message to the editor form instead of throwing raw\n  return $validation->getMessage();\n}","preventionTips":["Treat an empty tokenizer as an incomplete form: block save in the UI flow.","In scripts, assert non-empty arrays before posting trigger values.","Test trigger creation with empty selections to confirm the message renders inline."],"tags":["php","phabricator","project-triggers","form-validation"],"backgroundTag":"required-field-validation-failed","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}