/new_data/feedback TypeError: the JSON object must be str, bytes or bytearray, not dict

Open Beginner friendly
#166 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
flask, python
Domain
api, backend

Research direction

Start in flask_api.py at save_feedback around line 239 and inspect how request.get_json() is passed to json.loads(). Reproduce the POST to /new_data/feedback with the payload that triggered the stack trace; done means valid JSON requests no longer raise this TypeError or return HTTP 500.

Written by the indexing model from the issue text.

Description

bug

Stacktrace

May 28 09:44:03 AM  10.100.0.191 - - [28/May/2020:16:44:03 +0000] "GET / HTTP/1.1" 200 37 "-" "Render/1.0"
May 28 09:44:08 AM  10.104.30.4 - - [28/May/2020:16:44:08 +0000] "OPTIONS /new_data/feedback HTTP/1.1" 200 0 "https://nimbus.calpolycsai.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
May 28 09:44:08 AM  [2020-05-28 16:44:08,122] ERROR in app: Exception on /new_data/feedback [POST]
May 28 09:44:08 AM  Traceback (most recent call last):
  File "/opt/render/project/src/.venv/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/render/project/src/.venv/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/render/project/src/.venv/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/opt/render/project/src/.venv/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/opt/render/project/src/.venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/opt/render/project/src/.venv/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/render/project/src/.venv/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/render/project/src/flask_api.py", line 239, in save_feedback
    data = json.loads(request.get_json())
  File "/usr/local/lib/python3.7/json/__init__.py", line 341, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not dict
May 28 09:44:08 AM  10.104.30.4 - - [28/May/2020:16:44:08 +0000] "POST /new_data/feedback HTTP/1.1" 500 290 "https://nimbus.calpolycsai.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
Dominant language
Python
Stars
9
Forks
4
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from calpoly-csai/api

All issues in calpoly-csai/api

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.