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 ] Unexpected behavior on 204 response from RTR_DeleteSession #953

Closed
khyberspache opened this issue Apr 17, 2023 · 0 comments · Fixed by #954 or #957
Closed

[ BUG ] Unexpected behavior on 204 response from RTR_DeleteSession #953

khyberspache opened this issue Apr 17, 2023 · 0 comments · Fixed by #954 or #957
Assignees
Labels
bug 🐛 Something isn't working RTR Real Time Response issues and questions

Comments

@khyberspache
Copy link
Contributor

khyberspache commented Apr 17, 2023

Describe the bug
Using FalconPy to delete a session returns a 204 from the API, but the JSONDecoderError is not handled resulting in an error 500.

This snippet produces the anticipated response from the API (a 204), but the JSON decoder exception handler does not capture the error properly.

delete = connection.command("RTR_DeleteSession", session_id=resources[session]['session_id'])

You can see the Debug response here in urllib3 showing the 204 with an empty content, followed by the unhandled JSON decode error:
image

The core problem appears to be that the AWS Lambda Runtime environment leverages the simplejson instead of json package. Full stack trace:

[ERROR]	2023-04-16T23:51:06.345Z	75589bd5-05ac-46da-982f-e63ec503ce44	Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/opt/python/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/var/runtime/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/var/runtime/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/var/runtime/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/python/falconpy/_util.py", line 270, in perform_request
    content_return = Result()(response.status_code, response.headers, response.json())
  File "/opt/python/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

To Reproduce

  1. Create a simple AWS Lambda containing code to Init an RTR session
  2. Call the delete = connection.command("RTR_DeleteSession", session_id=resources[session]['session_id'])

Expected behavior
The RTR_DeleteSession should return with a 204 status and No Content body.

Environment (please complete the following information):

  • OS: AWS Lambda Runtime
  • Python: 3.9
  • FalconPy: 1.2.13

Additional context
I've written a simple patch for this bug in my own forked repo. Will attach the PR here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working RTR Real Time Response issues and questions
Projects
None yet
2 participants