Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ BUG ] json responses with charset specification in the content-type isn't parsed as json #708

Closed
hod-alpert opened this issue Jul 6, 2022 · 1 comment · Fixed by #709 or #710
Assignees
Labels
bug 🐛 Something isn't working SDK usage General SDK usage issues and questions

Comments

@hod-alpert
Copy link
Contributor

Describe the bug
When performing requests via the perform_request method It checks if content-type is application/json, and if so - return the json parsed response.

returning_content_type = response.headers.get('content-type')
if returning_content_type == "application/json":
    content_return = Result()(response.status_code, response.headers, response.json())

But when response's content-type has charset specification (i.e content-type: application/json; charset=utf-8) it ignores it and return the bytes content instead of a dict.
To Reproduce
Make a graphql request via IdentityProtection.

from falconpy import IdentityProtection
falcon = IdentityProtection(client_id=client_id, client_secret=client_secret)
query = """{
  entities(types: [USER],
  minRiskScoreSeverity: NORMAL,
  sortKey: RISK_SCORE,
  sortOrder: DESCENDING,
  first: 1000) {
    nodes {
      ... on UserEntity {
        emailAddresses
        riskScoreSeverity
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}
"""
resp = falcon.graphql(query=query)

Expected behavior
Instead of checking exact match - checking for application/json prefix in the content-type header.

Environment (please complete the following information):

  • OS: Linux
  • Python: 3.9
  • FalconPy: 1.1.4
@hod-alpert hod-alpert added the bug 🐛 Something isn't working label Jul 6, 2022
@hod-alpert hod-alpert changed the title [ BUG ] json responses with charset sepcification in the content-type aren't parsed as json [ BUG ] json responses with charset sepcification in the content-type isn't parsed as json Jul 6, 2022
hod-alpert added a commit to hod-alpert/falconpy that referenced this issue Jul 6, 2022
@jshcodes
Copy link
Member

jshcodes commented Jul 6, 2022

This is a good catch.

Thank you for reporting and resolving this! Your pull request is under review now. 😄

@jshcodes jshcodes self-assigned this Jul 6, 2022
@jshcodes jshcodes added the SDK usage General SDK usage issues and questions label Jul 6, 2022
@jshcodes jshcodes changed the title [ BUG ] json responses with charset sepcification in the content-type isn't parsed as json [ BUG ] json responses with charset specification in the content-type isn't parsed as json Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working SDK usage General SDK usage issues and questions
Projects
None yet
2 participants