Skip to content

fix(observability): reject malformed JSON-looking alert evidence - #480

Merged
seonghobae merged 3 commits into
mainfrom
fix/observability-malformed-json-lines
Aug 23, 2026
Merged

fix(observability): reject malformed JSON-looking alert evidence#480
seonghobae merged 3 commits into
mainfrom
fix/observability-malformed-json-lines

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Purpose

Test-first repair of an observability-evidence integrity gap. Protected source intentionally tolerates plain Wrangler diagnostic noise, but its broad per-line catch also silently drops malformed JSON-looking NDJSON. A truncated /exchange failure record can therefore disappear from alert aggregation instead of failing closed.

RED → candidate

  • protected/live base: 3d2425fc908ef221d55be958a66d26fb2ea8b94a
  • RED head: d35baf78ed34853821487cd11eba8e89477c55cb
  • RED application CI: 32608420133, job 97117236832, exact checkout d35baf78...; release tests failed exactly because the new realistic CLI test expected exit 1 but protected production returned exit 0 after silently dropping the truncated JSON-looking /exchange record
  • current candidate head: b734a2a208fadd57821b64c0428963139318d15d
  • RED→candidate production delta: scripts/evaluate-observability-alerts.mjs only, +4/-0

The production repair keeps the existing tolerance for plain Wrangler diagnostic noise, but a failed parse for a line that begins as structured JSON ({ or [, allowing leading whitespace) now exits fail-closed with line-specific Malformed JSON diagnostics. Existing fatal UTF-8, duplicate decoded-key, timestamp/status/latency validation and alert aggregation remain unchanged.

An intermediate candidate moved the entire aggregation block outside the parser try/catch; it was deliberately tightened back to the four-line causal repair so the final candidate has the smallest blast radius.

Exact-head evidence boundary

Fresh candidate application CI 32608613022, reviewer-ci 32608612902, and central Security Scan 32608612995 are non-passing until terminal-success on unchanged b734a2a.... Keep Draft until all applicable exact-head gates pass and zero valid unresolved findings remain.

Authority boundary

This hardens local retained observability evidence only. It does not manufacture production KPI, deployment, customer, release, legal/IP, or acquisition-ready evidence. No central .github or other dedicated-writer source is modified.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 16 minutes

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d898e46a-5b06-4784-8640-09cb70c17a52

📥 Commits

Reviewing files that changed from the base of the PR and between 3d2425f and b734a2a.

📒 Files selected for processing (2)
  • scripts/evaluate-observability-alerts.mjs
  • test/observability-alert-input-integrity.test.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae marked this pull request as ready for review August 23, 2026 00:46
@seonghobae
seonghobae merged commit 52e786e into main Aug 23, 2026
16 of 17 checks passed
@seonghobae
seonghobae deleted the fix/observability-malformed-json-lines branch August 23, 2026 00:46

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Open in Devin Review

Comment on lines +138 to +141
if (/^\s*[\[{]/.test(line)) {
console.error(`Malformed JSON in observability log line ${index + 1}.`);
process.exit(1);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Behavior change missing from changelog

The alert script now exits with an error on malformed JSON-looking lines instead of dropping them, a behavior change, yet CHANGELOG.md's ## Unreleased section gets no entry. CONTRIBUTING.md and CLAUDE.md require a changelog entry for every behavior change.

Prompt for agents
CONTRIBUTING.md and CLAUDE.md require that CHANGELOG.md's ## Unreleased section be updated with every behavior change. This PR changes the behavior of scripts/evaluate-observability-alerts.mjs so that lines beginning with { or [ (after optional whitespace) that fail to parse now cause a fail-closed exit(1) with a 'Malformed JSON' diagnostic, rather than being silently tolerated. Add a corresponding entry (in Korean, matching the existing changelog style) to the ## Unreleased section of CHANGELOG.md describing this fail-closed hardening.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +138 to 142
if (/^\s*[\[{]/.test(line)) {
console.error(`Malformed JSON in observability log line ${index + 1}.`);
process.exit(1);
}
// Wrangler tail can include non-JSON diagnostic lines. Preserve that noise tolerance.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Bracket-prefixed diagnostic lines now fail closed

The new guard exits with an error on any unparseable line starting with { or [. The retained comment states diagnostic noise from wrangler tail must stay tolerated, yet some diagnostic lines start with [ (e.g. [wrangler:inf] ..., [mf:inf] ...). If any such line reaches the log file, a valid run fails closed. Confirm the redirected tail output never contains bracket-prefixed diagnostics.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant