feat(hub): time-limited fixed patterns — expire after N days (BIT-26790)
CI / Test ingest-api (push) Successful in 48s
CI / Test api (push) Successful in 47s
CI / Lint and typecheck admin-ui (push) Successful in 1m20s
CI / Validate Docker build (push) Successful in 4m29s

Add optional addedAt + expiresAfterDays to FixedPattern so each pattern
has a TTL. The resolve-fixed-patterns handler now skips expired patterns,
letting persistent errors resurface and forcing a real code fix instead
of indefinite suppression.

- Transient infra patterns (WSREP, Google API, session write) carry addedAt
  for audit but no expiry — they are permanent noise with no code fix.
- fix-duplicate-logo.js expires 14 days after 2026-07-17; if still firing
  after that the deploy or client filter is broken and needs attention.
- Response includes expired_pattern_count and per-pattern expired/expires_at.
This commit is contained in:
David Santos committed 2026-07-17 22:42:56 +00:00
1 parent 37ab9f1ccb
commit caeb37ff0a
2 files changed
+45 -4

No files matched your search

+22 -2
View File
@@ -2,17 +2,30 @@
* Known-resolved error patterns for the hub resolve-fixed-patterns endpoint (BIT-25072).
* Each entry matches against er_incident_occurrences.message (via LIKE or exact).
*
* Schema: { messagePatterns: string[], note: string }
* Schema: { messagePatterns, note, addedAt?, expiresAfterDays? }
* messagePatterns: SQL LIKE patterns (use % wildcards). All patterns in an entry are AND-ed.
* note: human-readable reason / fix reference (written to er_incident_state_history.change_note).
* addedAt: ISO date when this pattern was added (YYYY-MM-DD).
* expiresAfterDays: if set, the pattern stops auto-resolving this many days after addedAt.
* This forces errors that persist beyond the grace period back to open state, ensuring the
* fix landed in code and wasn't just hidden. Omit for permanent patterns (transient infra noise
* with no code fix expected). See BIT-26790.
*
* Transient infrastructure errors: noise from known-bad infra states that self-resolve.
* Fixed code errors: added after the fix is deployed to production.
* Fixed code errors: added after the fix is deployed to production — set expiresAfterDays.
*/
export interface FixedPattern {
/** Each element becomes: o.message LIKE ? (all AND-ed together for this entry). */
messagePatterns: string[];
note: string;
/** ISO date (YYYY-MM-DD) when this pattern was added. */
addedAt?: string;
/**
* Days after addedAt when this pattern expires and stops auto-resolving.
* Expired patterns are skipped so the error resurfaces if it still occurs,
* signalling that the code fix hasn't landed yet. Omit for permanent patterns.
*/
expiresAfterDays?: number;
}
const patterns: FixedPattern[] = [
@@ -20,29 +33,36 @@ const patterns: FixedPattern[] = [
{
messagePatterns: ['%WSREP has not yet prepared node%'],
note: 'Transient: Galera cluster node not ready; infrastructure',
addedAt: '2026-06-13',
},
// Google API backendError — transient external
{
messagePatterns: ['%Internal error encountered%', '%backendError%'],
note: 'Transient: Google API 500 backendError; external; no code fix',
addedAt: '2026-06-13',
},
// Session write fails when DB is unavailable (cascading)
{
messagePatterns: ['%session_write_close(): Failed to write session data%'],
note: 'Transient: cascades from DB unavailability; no code fix',
addedAt: '2026-06-13',
},
// Storage / COMMIT transient
{
messagePatterns: ['%No such device or address%'],
note: 'Transient: storage/infrastructure during COMMIT; retry on next request',
addedAt: '2026-06-13',
},
// CRM: fix-duplicate-logo.js load failure (BIT-25223 ERRCLUSTER:33b4e527d8fd)
// File is present and protected by CopyWebpackPlugin + deploy gate; client-side noise
// filter (PR #684) suppresses at source. Chrome-style messages include the URL; this
// pattern resolves any that still reach the hub. Firefox-style resolved by bulk-resolve.
// Expires after 14 days — if still occurring after that, the deploy or filter is broken.
{
messagePatterns: ['%fix-duplicate-logo.js%'],
note: 'Fixed: fix-duplicate-logo.js present + protected (BIT-25223); client noise filter PR #684',
addedAt: '2026-07-17',
expiresAfterDays: 14,
},
];
@@ -624,13 +624,33 @@ async function handleResolveFixedPatterns(request: FastifyRequest, reply: Fastif
const dryRun = Boolean(body.dry_run);
const { type, ref } = changedByRef(auth);
const details: Array<{ note: string; resolved?: number; would_resolve?: number }> = [];
const details: Array<{
note: string;
resolved?: number;
would_resolve?: number;
expired?: boolean;
expires_at?: string;
}> = [];
let total = 0;
let expiredCount = 0;
const nowMs = Date.now();
for (const pattern of fixedPatterns) {
if (pattern.messagePatterns.length === 0) {
continue;
}
// Skip patterns that have passed their expiry window (BIT-26790).
// Expired patterns stop suppressing so the error resurfaces if still present.
if (pattern.addedAt && pattern.expiresAfterDays !== undefined) {
const addedMs = new Date(pattern.addedAt).getTime();
const expiresAt = new Date(addedMs + pattern.expiresAfterDays * 86_400_000);
if (nowMs > expiresAt.getTime()) {
expiredCount += 1;
details.push({ note: pattern.note, expired: true, expires_at: expiresAt.toISOString().slice(0, 10) });
continue;
}
}
const likeClauses = pattern.messagePatterns.map(() => 'o.message LIKE ?').join(' AND ');
const params: string[] = pattern.messagePatterns;
@@ -707,13 +727,14 @@ async function handleResolveFixedPatterns(request: FastifyRequest, reply: Fastif
await auditMutation(request.server, request, auth, 'error_monitoring.resolve_fixed_patterns', 'batch', {
resolved: total,
pattern_count: fixedPatterns.length,
expired_pattern_count: expiredCount,
});
}
return void reply.send({
success: true,
message: dryRun ? `Would resolve ${total} incidents` : `Resolved ${total} incidents`,
data: { total, dry_run: dryRun, details },
data: { total, dry_run: dryRun, expired_pattern_count: expiredCount, details },
});
}