Skip to content

fix(perf): skip spans with non-numeric encoded_body_size in LargeHTTPPayloadDetector#119474

Closed
billyvg wants to merge 1 commit into
masterfrom
claude/serene-cannon-r33nmd
Closed

fix(perf): skip spans with non-numeric encoded_body_size in LargeHTTPPayloadDetector#119474
billyvg wants to merge 1 commit into
masterfrom
claude/serene-cannon-r33nmd

Conversation

@billyvg

@billyvg billyvg commented Jul 12, 2026

Copy link
Copy Markdown
Member

Summary

Fixes SENTRY-5R9RValueError: invalid literal for int() with base 10: '[NaN]' in LargeHTTPPayloadDetector.

Root cause: In large_http_payload_detector.py:59, http.response_content_length span data can arrive as the string '[NaN]' (from scrubbed or filtered browser payloads). The bare int(encoded_body_size) call raises ValueError, which propagates through detect_performance_problems → _run_legacy_detectors → run_detector_on_data and gets caught by the logging.exception("Failed to detect performance problems") path — generating a Sentry error on every affected span.

Evidence from Sentry issue:

  • 1,349 occurrences over 5 days (first seen 2026-07-07)
  • encoded_body_size = "'[NaN]'" visible in local variables
  • File: sentry/issue_detection/detectors/large_http_payload_detector.py, line 59

Fix: Wrap the int() conversion in a try/except ValueError and return early, skipping spans with unparseable body sizes.

# Before
if isinstance(encoded_body_size, str):
    encoded_body_size = int(encoded_body_size)

# After
if isinstance(encoded_body_size, str):
    try:
        encoded_body_size = int(encoded_body_size)
    except ValueError:
        return

A test test_skips_span_with_nan_encoded_body_size is added to confirm the behavior.

Claude session: https://claude.ai/code/session_015pwRdeFeVj3ZSak5yEbtaY

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.


Generated by Claude Code

…PayloadDetector

When `http.response_content_length` is a string like '[NaN]' (from scrubbed
or filtered span data), `int()` raises ValueError causing detection to fail
loudly. Wrap the conversion in try/except to skip such spans gracefully.

Fixes SENTRY-5R9R
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 12, 2026
@billyvg

billyvg commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

added encoded_body_size as safe field instead

@billyvg billyvg closed this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants