phacility/phabricator · error · DiffusionCommitHookRejectException
DANGEROUS CHANGE: Dangerous change protection is enabled…
Error message
DANGEROUS CHANGE: %s Dangerous change protection is enabled for this repository. Edit the repository configuration before making dangerous changes.
What it means
Push rejection from rejectDangerousChanges during hook execution: one of the ref updates carries the CHANGEFLAG_DANGEROUS flag, meaning it is a branch deletion or a non-fast-forward (history-rewriting) update, and the repository has dangerous-change protection enabled. The push is aborted before any refs move.
Solutions
- Disable 'dangerous change' protection in the repository's Edit Policies/Behavior configuration
- Re-push without deleting branches or rewriting history (fast-forward only)
- For deletions the owner intends, have an administrator temporarily lower protection
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/applications/diffusion/engine/DiffusionCommitHookEngine.php:295 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/cb8c24fe222a9a12.
Report an issue: GitHub.
Appendix: source
Thrown at src/applications/diffusion/engine/DiffusionCommitHookEngine.php:295
$flag_dangerous = PhabricatorRepositoryPushLog::CHANGEFLAG_DANGEROUS;
foreach ($ref_updates as $ref_update) {
if (!$ref_update->hasChangeFlags($flag_dangerous)) {
// This is not a dangerous change.
continue;
}
// We either have a branch deletion or a non fast-forward branch update.
// Format a message and reject the push.
$message = pht(
"DANGEROUS CHANGE: %s\n".
"Dangerous change protection is enabled for this repository.\n".
"Edit the repository configuration before making dangerous changes.",
$ref_update->getDangerousChangeDescription());
throw new DiffusionCommitHookRejectException($message);
}
}
private function findContentUpdates(array $ref_updates) {
assert_instances_of($ref_updates, 'PhabricatorRepositoryPushLog');
$type = $this->getRepository()->getVersionControlSystem();
switch ($type) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
return $this->findGitContentUpdates($ref_updates);
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
return $this->findMercurialContentUpdates($ref_updates);
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
return $this->findSubversionContentUpdates($ref_updates);
default:
throw new Exception(pht('Unsupported repository type "%s"!', $type));
}
}View on GitHub (pinned to 5720a38cfe)