feat(hub): expose occurred_at on recent-errors for CRM deploy verification
Add ISO-8601 occurred_at to each row returned by GET /api/error-monitoring/recent-errors so operators can script post-deploy stability checks (BIT-1048). Extend verify_pmx_bet_due_time_deploy.sh with a hub mode that queries open CRM incidents matching ERRSIG 90a47beec0d7 and fails if the latest occurrence is within HUB_DUE_TIME_STABILITY_SEC (default 7200). Skips with exit 0 when no resolve key is present. Document the field in HTTP_CONTRACTS, ERROR_MONITORING_PUBLIC_API, and RUNBOOK_REPORTER_CRM_TASKS_DUE_TIME §6.2.2. Paperclip-Agent: 5d084b36-f38f-42a5-a92a-520005afda4f Paperclip-Issue: BIT-1048 Paperclip-Run: 5138810f-9498-49a1-81eb-291fdeba8abc
This commit is contained in:
1 parent
50282ab4dd
commit
410cd7e0aa
5 files changed
+100
-3
No files matched your search
@@ -51,6 +51,8 @@ Alias: `GET /v1/paperclip/recent-errors`
|
||||
|
||||
Each row includes CRM-compatible fields. For non-resolved incidents, `status` is always `"open"` (including `investigating`) so Paperclip `error_loop` continues to treat rows as open.
|
||||
|
||||
**`occurred_at`:** ISO-8601 timestamp of the **latest** occurrence returned for that incident (same row as `unique_id`). Used by ops scripts to verify “no new events in the last *N* hours” after a deploy (see repo runbook `docs/RUNBOOK_REPORTER_CRM_TASKS_DUE_TIME.md` §6).
|
||||
|
||||
**`stack_trace`:** Non-empty for every row: missing client stacks are synthesized on ingest; legacy DB rows with null/blank `stack_trace` get the same synthesis when serializing this endpoint (BIT-1008).
|
||||
|
||||
**Example**
|
||||
|
||||
@@ -38,6 +38,24 @@ function parseJsonObject(raw: string | null): Record<string, unknown> | null {
|
||||
}
|
||||
}
|
||||
|
||||
function toIsoOccurredAt(value: unknown): string {
|
||||
if (value == null) {
|
||||
return '';
|
||||
}
|
||||
if (value instanceof Date) {
|
||||
return value.toISOString();
|
||||
}
|
||||
const s = String(value).trim();
|
||||
if (s === '') {
|
||||
return '';
|
||||
}
|
||||
const t = Date.parse(s);
|
||||
if (Number.isNaN(t)) {
|
||||
return s;
|
||||
}
|
||||
return new Date(t).toISOString();
|
||||
}
|
||||
|
||||
function extractFileLine(ctx: Record<string, unknown> | null): { file_path: string; line_number: string } {
|
||||
if (!ctx) {
|
||||
return { file_path: '', line_number: '' };
|
||||
@@ -205,6 +223,7 @@ async function handleRecentErrors(request: FastifyRequest, reply: FastifyReply):
|
||||
unique_id: String(row.occurrence_id ?? row.incident_id ?? ''),
|
||||
project_slug: String(row.project_slug ?? '').toLowerCase(),
|
||||
environment: String(row.environment ?? 'production'),
|
||||
occurred_at: toIsoOccurredAt(row.occurred_at),
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user