Skip to content

fix(uptime): only download body if necessary#487

Merged
klochek merged 3 commits intomainfrom
christopherklochek/download_body_bytes
Mar 3, 2026
Merged

fix(uptime): only download body if necessary#487
klochek merged 3 commits intomainfrom
christopherklochek/download_body_bytes

Conversation

@klochek
Copy link
Copy Markdown
Contributor

@klochek klochek commented Mar 2, 2026

We're always downloading the body now, because we want to capture it on potential errors. We only need the body if there is an error, though, and most of our checks via assertions won't need the body bytes, either. This reorganizes the code a bit to only download the body once, and only when necessary, either for assertion execution, or for error capture.

klochek added 2 commits March 2, 2026 16:11
We're always downloading the body now, because we want to capture it on potential errors.  We only need the body if there is an error, though, and most of our checks via assertions won't need the body bytes, either.  This reorganizes the code a bit to only download the body once, and only when necessary, either for assertion execution, or for error capture.
@klochek klochek requested a review from a team as a code owner March 2, 2026 21:25
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

scheduled_check.get_config().subscription_id,
err.to_string(),
);
return Check::assert_compile_failure(&err);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Early return drops body bytes, re-download gets nothing

Low Severity

When an assertion with requires_body() == true fails to compile, body bytes are consumed from the response stream inside to_check_result but then dropped by the early return Check::assert_compile_failure. The returned Check has body_bytes: None. Back in check_url, if capture is desired, read_body_bounded attempts to re-read the already-consumed response stream and gets empty data. The old code didn't have this problem because body was downloaded in check_url scope before calling to_check_result.

Additional Locations (1)

Fix in Cursor Fix in Web

@klochek klochek merged commit a455a9f into main Mar 3, 2026
14 checks passed
@klochek klochek deleted the christopherklochek/download_body_bytes branch March 3, 2026 19:24
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.

2 participants