News & Sentiment
#7 Fixing the News Page When AI Analysis Was Stuck at 0 AI Analyzed
· Build Log
A debugging story of empty analysis states, cache traps, and serve-path sanitation.
0 AI analyzednews cache bugserve-time sanitation
1) TL;DR
- The UI showed zero analyzed items even when raw news existed.
- Cached payloads lacked normalized fields expected by renderer.
- Serve-time sanitation and fallback parsing restored stable analysis counts.
2) What I Tried
I expanded ingestion and ranking but relied on brittle parse assumptions.
3) What Broke
Users saw zero analyzed cards or weak card details during active sessions.
4) Root Cause
Cache objects with incomplete normalized fields were treated as final analysis states.
5) Before (Code Path)
news path
- cached item could miss summary/reason
- renderer classified missing keys as non-analyzed
6) After (Code Path)
news path
+ sanitize cached summary/reason at read and write
+ stronger stale detection
+ fallback score extraction for partial model output
7) Evidence (Git History)
- 6728991 fix(news): sanitize cached summary/reason on every read and write.
- 6ba1266 fix(news): sanitize full-cache items on serve and expand stale detection.
- 642dc72 fix(ai-news): fallback score extraction when JSON fails.
8) What I Learned
Cache validity checks must run at serve-time, not only at write-time.
9) Frequently Asked Questions
Why did this persist across refreshes?
Because invalid cache objects were still considered valid output.
What fixed it permanently?
Schema sanitation plus stale-state detection and fallback parsing.
What user signal improved most?
The analyzed-count and card consistency on reload.