Giter Club home page Giter Club logo

Comments (4)

cofin avatar cofin commented on July 2, 2024

I think this has been resolved in the development branch. @zoopp are you able to give that branch a try to confirm if the problem remains?

from litestar.

zoopp avatar zoopp commented on July 2, 2024

@cofin I gave it a try now but the issue is still reproducible with the MCVE above:

!!! I'm using the standard logging version output as it formats the exception in a readable manner
!!! but the outcome is essentially the same regardless if using structlog or standard logging.

(litestar)
┌─┤10:11:07│mihai@mobilews:~/bug
└──────────╼ litestar --app bug:app run --reload
Using Litestar app from env: 'bug:app'
Starting server process ───────────────────────────────────────────────────────────────────────────────────────────────────────
┌──────────────────────────────┬──────────────────────┐
│ Litestar version             │ 2.6.0                │
│ Debug mode                   │ Disabled             │
│ Python Debugger on exception │ Disabled             │
│ CORS                         │ Disabled             │
│ CSRF                         │ Disabled             │
│ OpenAPI                      │ Enabled path=/schema │
│ Compression                  │ Disabled             │
│ Middlewares                  │ LoggingMiddleware    │
└──────────────────────────────┴──────────────────────┘
INFO:     Will watch for changes in these directories: ['/home/mihai/bug']
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [150319] using WatchFiles
INFO:     Started server process [150321]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     127.0.0.1:58246 - "POST / HTTP/1.1" 500 Internal Server Error
ERROR - 2024-02-05 10:11:12,310 - litestar - config - exception raised on http connection to route /

Traceback (most recent call last):
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/serialization/msgspec_hooks.py", line 186, in decode_json
    return _msgspec_json_decoder.decode(value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
msgspec.DecodeError: JSON is malformed: trailing comma in object (byte 10)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/exceptions/middleware.py", line 192, in __call__
    await self.app(scope, receive, send)
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/base.py", line 129, in wrapped_call
    await original__call__(self, scope, receive, send)  # pyright: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/logging.py", line 112, in __call__
    await self.log_request(scope=scope, receive=receive)
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/logging.py", line 126, in log_request
    extracted_data = await self.extract_request_data(request=scope["app"].request_class(scope, receive))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/logging.py", line 179, in extract_request_data
    value = await value
            ^^^^^^^^^^^
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/data_extractors.py", line 277, in extract_body
    return await request.json()
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/connection/request.py", line 134, in json
    self._json = self._connection_state.json = decode_json(
                                               ^^^^^^^^^^^^
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/serialization/msgspec_hooks.py", line 191, in decode_json
    raise SerializationException(str(msgspec_error)) from msgspec_error
litestar.exceptions.base_exceptions.SerializationException: JSON is malformed: trailing comma in object (byte 10)
Traceback (most recent call last):
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/serialization/msgspec_hooks.py", line 186, in decode_json
    return _msgspec_json_decoder.decode(value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
msgspec.DecodeError: JSON is malformed: trailing comma in object (byte 10)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/exceptions/middleware.py", line 192, in __call__
    await self.app(scope, receive, send)
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/base.py", line 129, in wrapped_call
    await original__call__(self, scope, receive, send)  # pyright: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/logging.py", line 112, in __call__
    await self.log_request(scope=scope, receive=receive)
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/logging.py", line 126, in log_request
    extracted_data = await self.extract_request_data(request=scope["app"].request_class(scope, receive))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/logging.py", line 179, in extract_request_data
    value = await value
            ^^^^^^^^^^^
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/data_extractors.py", line 277, in extract_body
    return await request.json()
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/connection/request.py", line 134, in json
    self._json = self._connection_state.json = decode_json(
                                               ^^^^^^^^^^^^
  File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/serialization/msgspec_hooks.py", line 191, in decode_json
    raise SerializationException(str(msgspec_error)) from msgspec_error
litestar.exceptions.base_exceptions.SerializationException: JSON is malformed: trailing comma in object (byte 10)

from litestar.

github-actions avatar github-actions commented on July 2, 2024

This issue has been closed in #3109. The change will be included in the upcoming patch release.

from litestar.

github-actions avatar github-actions commented on July 2, 2024

A fix for this issue has been released in v2.6.1

from litestar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.