{"record":{"id":"5a05020a10743ba9","repo":"phacility/phabricator","slug":"storage-patch-s-specifies-it-should-apply-in-ph","errorCode":null,"errorMessage":"Storage patch \"%s\" specifies it should apply in phase \"%s\", but this phase is unrecognized. Valid phases are: %s.","messagePattern":"Storage patch \"(.+?)\" specifies it should apply in phase \"(.+?)\", but this phase is unrecognized\\. Valid phases are: (.+?)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/infrastructure/storage/patch/PhabricatorSQLPatchList.php","lineNumber":157,"sourceCode":"          if ($namespace != 'phabricator') {\n            throw new Exception(\n              pht(\n                \"Only patches in the '%s' namespace may contain '%s' keys.\",\n                'phabricator',\n                'legacy'));\n          }\n        } else {\n          $patch['legacy'] = false;\n        }\n\n        if (!array_key_exists('phase', $patch)) {\n          $patch['phase'] = $default_phase;\n        }\n\n        $patch_phase = $patch['phase'];\n\n        if (!isset($phases[$patch_phase])) {\n          throw new Exception(\n            pht(\n              'Storage patch \"%s\" specifies it should apply in phase \"%s\", '.\n              'but this phase is unrecognized. Valid phases are: %s.',\n              $full_key,\n              $patch_phase,\n              implode(', ', array_keys($phases))));\n        }\n\n        $last_key = $last_keys[$patch_phase];\n\n        if (!array_key_exists('after', $patch)) {\n          if ($last_key === null && $patch_phase === $default_phase) {\n            throw new Exception(\n              pht(\n                \"Patch '%s' is missing key 'after', and is the first patch \".\n                \"in the patch list '%s', so its application order can not be \".\n                \"determined implicitly. The first patch in a patch list must \".\n                \"list the patch or patches it depends on explicitly.\",","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/storage/patch/PhabricatorSQLPatchList.php#L139-L175","documentation":"Storage patches are grouped into execution phases (defined by PhabricatorStoragePatch::getPhaseList(), currently 'default' and 'worker') so critical patches can run before workers restart during an upgrade. A patch that sets a 'phase' key with a value not in that list is a typo or an invented phase, and the loader aborts because ordering across phases cannot be validated.","triggerScenarios":"A patch spec contains 'phase' => 'something' where 'something' is not exactly 'default' or 'worker' (e.g. 'default ', 'Worker', 'compat', 'setup'). Fires during PhabricatorSQLPatchList::buildAllPatches() on any storage-management command.","commonSituations":"Guessing phase names when adding a patch to a fork; copying a phase name from an incompatible Phabricator version where the phase list differed; case or whitespace mistakes in the literal.","solutions":["Change the 'phase' value to one of the phases listed in the error message ('default' or 'worker').","If ordinary ordering is fine, delete the 'phase' key entirely — absent means the default phase.","Use PhabricatorStoragePatch::PHASE_DEFAULT / PHASE_WORKER literals rather than raw strings to avoid typos.","Re-run 'bin/storage status' to confirm the list loads."],"exampleFix":"// before\n'20180101.daemon.sql' => array(\n  'type' => 'sql',\n  'name' => $this->getPatchPath('20180101.daemon.sql'),\n  'phase' => 'daemon',\n),\n\n// after\n'20180101.daemon.sql' => array(\n  'type' => 'sql',\n  'name' => $this->getPatchPath('20180101.daemon.sql'),\n  'phase' => PhabricatorStoragePatch::PHASE_WORKER,\n),","handlingStrategy":"validation","validationCode":"// Validate phase literals against the engine's own list:\n$valid_phases = array_fuse(PhabricatorStoragePatch::getPhaseList());\nforeach ((new MyApplicationPatchList())->getPatches() as $key => $patch) {\n  if (isset($patch['phase']) && !isset($valid_phases[$patch['phase']])) {\n    throw new Exception(\"Patch {$key} has unknown phase '{$patch['phase']}'\");\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the constants PhabricatorStoragePatch::PHASE_DEFAULT / PHASE_WORKER instead of raw strings.","Omit 'phase' entirely unless you specifically need worker-phase execution."],"tags":["phabricator","database-migration","phases","php"],"backgroundTag":"database-migration-validation","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}