Show explicit blocking gate errors in promote script

This commit is contained in:
Hamza-Ayed
2026-09-10 23:28:09 +03:00
parent 12fb6d07e6
commit c280cfc004
@@ -48,6 +48,20 @@ $gateJson = shell_exec(
$gate = json_decode((string) $gateJson, true);
if (!is_array($gate) || ($gate['status'] ?? null) !== 'passed') {
fwrite(STDERR, "Promotion refused: intake gate did not pass for {$manifestName}.\n");
if (is_array($gate) && !empty($gate['errors'])) {
fwrite(STDERR, sprintf("Gate reported %d blocking error(s):\n", count($gate['errors'])));
foreach (array_slice($gate['errors'], 0, 10) as $err) {
$contextFile = $err['context']['file'] ?? ($err['context']['path'] ?? '');
fwrite(STDERR, sprintf(" - [%s] %s%s\n", $err['code'] ?? 'error', $err['message'] ?? '', $contextFile ? " ({$contextFile})" : ''));
}
if (count($gate['errors']) > 10) {
fwrite(STDERR, sprintf(" ... and %d more error(s). Run: php backend/scripts/validate_grade10_candidate.php --manifest=%s\n", count($gate['errors']) - 10, basename($manifestName)));
}
} elseif (empty($gateJson)) {
fwrite(STDERR, "Preflight gate failed to execute or returned empty output.\n");
fwrite(STDERR, "Run the gate directly to see the exact issue:\n");
fwrite(STDERR, " php backend/scripts/validate_grade10_candidate.php --manifest=" . basename($manifestName) . "\n");
}
fwrite(STDERR, "Resolve review-queue.json items first; quarantined files stay unpublished.\n");
exit(1);
}