feat(hub): time-limited fixed patterns — expire after N days (BIT-26790)
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:
1 parent
37ab9f1ccb
commit
caeb37ff0a
2 files changed
+45
-4
No files matched your search
@@ -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 },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user