Skip to content

Trying to return entity but Validation error gets raised #296

Answered by josushiman
josushiman asked this question in Q&A
Discussion options

You must be logged in to vote

I ended up finding what the cause was. For some reason, even though a City model is returned, having it set in the response model was causing it to throw the Internal Server Error i shared above.

The only change i had to make was this:

@router.get("/")
async def get_city(iata: str) -> City:
    result = await db.get_by_kwarg(City, {
        "iata" : iata
    })

    return result

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@collerek
Comment options

@josushiman
Comment options

Answer selected by josushiman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants