Skip to content

fix(core): stop recording read cache hits as span errors - #1761

Merged
phernandez merged 1 commit into
mainfrom
fix-read-cache-hit-span
Oct 12, 2026
Merged

phernandez merged 1 commit into
mainfrom
fix-read-cache-hit-span

Conversation

@phernandez

Copy link
Copy Markdown
Member

Summary

Found testing development after #1752. fastapi-redis-sdk signals a cache hit by raising CacheHitException, which is control flow and not a failure. read_cache.read_through re-raised it inside with logfire.span(...), so Logfire closed the span as failed.

On development, every hit span had level 17 (error), status ERROR and an exception event: 35 of 35 hits, 0 of 72 misses. In production that would fill Logfire exception issues and error-rate views, and bill every hit as an error record.

Change

routes.py keeps the hit and raises it after the span closes. The span still records cache.lookup.outcome = hit and the hit headers. The SDK handler still turns the exception into the cached response.

Tests

  • test_each_cached_read_reports_one_span_with_its_outcome now also checks that no read-through span has an exception event or an error level. It fails without the fix.
  • test-int/read_cache: 76 passed. tests/test_read_cache_*: 15 passed. just fast-check passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_016N9c6ouiT4Wid3arGR41Dv

fastapi-redis-sdk signals a hit by raising CacheHitException. The
read_cache.read_through span re-raised it inside the span, so Logfire
marked every hit as an error (level 17, status ERROR, exception event).
On development every hit did this. Raise the hit after the span closes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016N9c6ouiT4Wid3arGR41Dv
Signed-off-by: phernandez <paul@basicmachines.co>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T05:13:07.909414Z b67a97d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@phernandez
phernandez merged commit 76c2acf into main Oct 12, 2026
31 checks passed
@phernandez
phernandez deleted the fix-read-cache-hit-span branch October 12, 2026 13:52
phernandez added a commit that referenced this pull request Oct 23, 2026
Date the v0.24.0 entry 2026-10-22, add a Security section for
GHSA-4gfv-c2mm-mvj2 (DNS rebinding, #1697) and GHSA-pqm2-2wxw-p5hx
(host symlink probing, #1807), plus #1804 and #1805, and cover the
changes merged since the entry was last edited (#1761 through #1807).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk
Signed-off-by: phernandez <paul@basicmachines.co>
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