feat(uptime): remove built-in 2xx status code check#484
Open
evanpurkhiser wants to merge 2 commits intomainfrom
Open
feat(uptime): remove built-in 2xx status code check#484evanpurkhiser wants to merge 2 commits intomainfrom
evanpurkhiser wants to merge 2 commits intomainfrom
Conversation
Relies on assertions to validate responses instead of a hard-coded 2xx check. When no assertion is configured, any response is considered a success. Callers are expected to configure a status code assertion to validate the response code. Fixed [NEW-758](https://linear.app/getsentry/issue/NEW-758/remove-built-in-status-code-check-from-uptime-checker)
Comment on lines
334
to
342
| max_assertion_ops, | ||
| region, | ||
| ) | ||
| } else if r.status().is_success() { | ||
| Check::success() | ||
| } else { | ||
| Check::code_failure(r.status()) | ||
| Check::success() | ||
| } | ||
| } else { | ||
| // TODO: rust 2024 allows let-chaining, so the enclosing if-statement can be | ||
| // folded into the the if let | ||
| match r.status().is_success() { | ||
| true => Check::success(), | ||
| false => Check::code_failure(r.status()), | ||
| } | ||
| Check::success() | ||
| } |
There was a problem hiding this comment.
Bug: Uptime checks without an explicit assertion now treat non-2xx HTTP responses as successful, which can lead to silent failures for existing checks.
Severity: HIGH
Suggested Fix
To prevent silent failures for existing checks, consider adding a default status code assertion when a CheckConfig is loaded without one. For example, if check.get_config().assertion is None, automatically apply an assertion that validates the status code is within the 2xx range. This would maintain backward compatibility while still allowing users to override it with explicit assertions.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/checker/reqwest_checker.rs#L334-L342
Potential issue: The pull request removes the implicit validation of 2xx HTTP status
codes for uptime checks. In the new implementation, if a `CheckConfig` does not have an
explicit `assertion` configured, any HTTP response, including those with 4xx or 5xx
status codes, will be considered a success. This is a breaking change from the previous
behavior where non-2xx responses were automatically treated as failures. Existing uptime
checks that rely on this implicit validation will now silently report success even when
the service is down, potentially leading to undetected outages.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relies on assertions to validate responses instead of a hard-coded 2xx
check. When no assertion is configured, any response is considered a
success. Callers are expected to configure a status code assertion to
validate the response code.
Fixed NEW-760: Remove hard-coded 2xx status check from uptime checker