Repository navigation
fix: preserve non-JSON response bodies instead of discarding them (Fixes #1498) - #1510
Merged
jshcodes merged 1 commit intoSep 23, 2026
Merged
Conversation
MRX-72
requested review from
alhumaw,
crowdstrikedcs and
jshcodes
as code owners
September 14, 2026 21:38
2 tasks done
perform_request raised NoContentWarning for any body that failed JSON parsing, which includes a non-empty non-JSON body such as the plain-text diagnostics NGSIEM returns for a CQL syntax error. The caller was told 'No content was received for this request.' even though content was received, silently dropping server-side diagnostics. Distinguish an empty body from a non-empty, non-JSON one. When a body is present, surface it via a new NonJsonContentWarning that subclasses NoContentWarning (so existing handlers keep working) and carries the raw text in its result. Empty bodies keep the original NoContentWarning behavior. Fixes CrowdStrike#1498
jshcodes
force-pushed
the
fix/issue-1498-preserve-non-json-body
branch
from
September 23, 2026 14:57
5a79c48 to
f60c13d
Compare
jshcodes
approved these changes
Sep 23, 2026
jshcodes
left a comment
Member
There was a problem hiding this comment.
Thank you for your contribution!! 🙇
Member
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.
Pull Request
Preserve non-JSON response bodies instead of discarding them.
Summary
perform_request raised NoContentWarning for any response body that failed JSON parsing - not just empty bodies, but non-empty bodies that simply aren't JSON, like the text/plain CQL error diagnostics NGSIEM/LogScale returns. So the caller got "No content was received for this request" even though content was received, and the actual error text was thrown away.
The fix tells those two cases apart. A non-empty, non-JSON body now raises a new NonJsonContentWarning that carries the raw text; an empty body keeps the original NoContentWarning behaviour. NonJsonContentWarning subclasses NoContentWarning, so anything already catching NoContentWarning (including the SDK's own force_default) keeps working - callers just get the real diagnostic instead of the placeholder, and can read the body if they want it.
Empty-response behaviour is unchanged; the change is additive.
Testing
Three offline tests in tests/test_api_request.py cover the non-JSON body being preserved, the empty body still reporting no content, and the warning retaining its body. flake8, bandit and pylint are clean on the changed files.
Fixes #1498