{
"detail": [
{
"type": "bool_parsing",
"loc": [
"path",
"status_field"
],
"msg": "Input should be a valid boolean, unable to interpret input",
"input": "all"
}
]
}
FASTAPI개발 과정 중 해당 오류가 발생하였다. 해당 오류를 살펴보면 msg에 bool 타입이 들어와야하는데 해석할 수 없는 input이 들어왔다고 쓰여있다. 그리고 해당 input은 all이라는 뜻이다. 내가 요청한 경로는 /list/all이라는 경로였는데 all이 bool타입이란 것이라서 이해가 안갔다.
해당 오류가 난 이유는 코드 순서 때문이다.
@router.get("/list/{status_field}",
)
async def chat_list(
request: Request,
status_field: Annotated[bool, Path(
)]
): ...
)
@router.get("/list/all",
response_model=ResponseModel,
)
async def list_all(
request: Request,
): ...
두 코드가 있었는데 밑의 코드가 더 아래에 있기는 했다. 때문에 위의 url로 접속했기 때문에 해당 오류가 발생하였다. 위아래의 코드 순서를 변경하니 오류가 해결되었다. 구체적인 status를 넣는 부분이 있기에 위의 코드가 위에 있는 것이 맞다고 생각했는데 아래의 일반 url의 순서가 먼저 오고, parameter값이 오는 것이 맞다. 사실 url자체가 비슷한 것을 수정하는 것이 맞다고 생각하긴 한다.