Skip to content

fix: preserve non-JSON response bodies instead of discarding them (Fixes #1498) - #1510

Merged
jshcodes merged 1 commit into
CrowdStrike:devfrom
MRX-72:fix/issue-1498-preserve-non-json-body
Sep 23, 2026
Merged

jshcodes merged 1 commit into
CrowdStrike:devfrom
MRX-72:fix/issue-1498-preserve-non-json-body

Conversation

@MRX-72

@MRX-72 MRX-72 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

Preserve non-JSON response bodies instead of discarding them.

  • Bug fixes
  • Updated unit tests

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

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
jshcodes force-pushed the fix/issue-1498-preserve-non-json-body branch from 5a79c48 to f60c13d Compare September 23, 2026 14:57

@jshcodes jshcodes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your contribution!! 🙇

@jshcodes

Copy link
Copy Markdown
Member

Related to #1508 and #1509. Merging to dev for additional unit testing and confirmation.

Planned for inclusion in the v1.6.6 release.

@jshcodes
jshcodes merged commit d2f4325 into CrowdStrike:dev Sep 23, 2026
5 checks passed
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.

[ BUG ] Non-JSON error bodies are discarded and replaced with "No content was received for this request."

2 participants