agentless: less strict checking of response status codes#243
Merged
agentless: less strict checking of response status codes#243
Conversation
Checking specific values of status codes causes more harm than good. Throwing errors when we get a 200 instead of 204 has no benefit. Either way, the request succeeded. Throwing an error that users have no way to handle just causes unnecessary stack failures. Even unsuccessful status codes are not necessarily a problem. If a delete request fails with 404, that just means that the resource has already been deleted, i.e. the system is already in the desired state. It makes no sense to fail the stack deletion because of this, creating a problem where there was none.
For most client errors, the best option is to continue with the stack deletion, since users have no way to fix the request, and at least this way they can clean up the scanner resources. An exception might be 429 Too Many Requests, where one could just try deleting the stack later, but it really doesn't make sense to block a stack deletion for that reason.
jinroh
approved these changes
Sep 1, 2025
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.
What does this PR do?
Motivation
The initial motivation was allowing the PATCH response to include the updated resource (with status 200 instead of 204).
However, instead of simply allowing an extra status code, I decided to remove most of the checks.
Checking specific values of status codes causes more harm than good. Throwing errors when we get a 200 instead of 204 has no benefit. Either way, the request succeeded. Throwing an error that users have no way to handle just causes unnecessary stack failures.
Even unsuccessful status codes are not necessarily a problem. If a delete request fails with 404, that just means that the resource has already been deleted, i.e. the system is already in the desired state. It makes no sense to fail the stack deletion because of this, creating a problem where there was none.
Testing Guidelines
Tested scenarios: