You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cannot get msgpack-asgi running with FastAPI. Any request with msgpack-bytes is returned with a "422 Unprocessable Entity" error. The following minimal example will show the problem:
from pathlib import Path
import uvicorn
from fastapi import FastAPI
from pydantic import BaseModel
from msgpack_asgi import MessagePackMiddleware
class Foo(BaseModel):
bar: int
app = FastAPI()
app.add_middleware(MessagePackMiddleware)
@app.post("/")
def index(thing: Foo):
return thing
if __name__ == "__main__":
uvicorn.run(f"{Path(__file__).stem}:app", host="0.0.0.0", port=5001, log_level="debug", reload=True)
So the data is accepted as json but refused as msgpack-bytes. May there be an incompatibility with newser versions of FastAPI or pydantic? Or am I just using this completely wrong?
The text was updated successfully, but these errors were encountered:
This does seem to be a FastAPI compatibility issue. Something's happening or interacting with FastAPI that makes this 422 error pop out on the FastAPI side.
For reference, here's an equivalent Starlette example that does work as intended, and illustrates what I would expect FastAPI to do — i.e. treat the incoming request as a JSON one from its own POV:
Your guess about a recent incompatibility seems accurate. I pinned down the FastAPI version that introduces this error to fastapi==0.65.2 (see release notes).
I cannot get msgpack-asgi running with FastAPI. Any request with msgpack-bytes is returned with a "422 Unprocessable Entity" error. The following minimal example will show the problem:
The data is sent with the following snippet:
Resulting in:
So the data is accepted as json but refused as msgpack-bytes. May there be an incompatibility with newser versions of FastAPI or pydantic? Or am I just using this completely wrong?
The text was updated successfully, but these errors were encountered: