fix(kpi): reject malformed JSON-looking threshold evidence - #483
Conversation
|
Warning Review limit reached
Next review available in: 56 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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
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. Comment |
| if (/^\s*[\[{]/.test(line)) { | ||
| console.error(`Malformed JSON in KPI log line ${index + 1}.`); | ||
| process.exit(1); |
There was a problem hiding this comment.
🟡 Malformed-JSON diagnostic reports wrong line number
lines drops blank lines via filter(Boolean), so the index from lines.entries() is a position in the filtered array, not the file line. Any blank line before a malformed JSON-looking line makes the reported line N point at the wrong line.
Was this helpful? React with 👍 or 👎 to provide feedback.
Purpose
Test-first repair of the threshold KPI evidence parser.
scripts/check-kpi.mjsalready fails closed on UTF-8, duplicate-key, status, latency and timestamp corruption, but its JSON parse catch previously silently treated malformed structured NDJSON as Wrangler diagnostic noise. A truncated/exchangerecord could therefore disappear before threshold/window evaluation.RED → GREEN
f726c9157120866c1979272a4dd3eec5e2a329b2c634eb25fc1138ebee98e41aa2ee9ab22364e9bf32609511110, job97120093652: exact checkout/base/toolchain passed; the single new regression failed because malformed structured JSON was dropped and the script reported onlyNo exchange events found.5f88bda2280fb61c549ad7850785b68c1c9ddfbebac746ffdcda2ad4db2c4a9d042ab8563059660bExact-head verification
On unchanged
bac746ffdcda2ad4db2c4a9d042ab8563059660band live base59739e2b37e80d52e37093d9f3252332a2da1eb7:32609737644: terminal success32609737596: terminal success32609737583: terminal successAuthority boundary
This protects threshold/window computation from silently discarded malformed evidence. It does not create production KPI provenance, a 30-day window, release/deployment evidence, revenue or acquisition authority.