fastapi: 404 Error with OpenAPI

Hi all,

New to fastAPI, and coming from Flask, I’m very impressed by the solution. But using the OpenAPI documentation/UI, I can see in the logs that I have the following issue each time I extend a resource/API : INFO: <IP>:57175 - "GET /%5Bobject%20Module%5D HTTP/1.1" 404 Not Found The API is working, but I get this error in the log.

I’m using v0.63.0, on an ubuntu server (18.04)

Thanks a lot for your support.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 17
  • Comments: 27 (3 by maintainers)

Most upvoted comments

Created a pull request with a temporary fix to this (#2656). Thanks @Gatux for linking the issue with the monkey patch.

I also get the samme INFO message in my log

TRACE:    127.0.0.1:44588 - ASGI [10] Started scope={'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.1'}, 'http_version': '1.1', 'server': ('127.0.0.1', 8000), 'client': ('127.0.0.1', 44588), 'scheme': 'http', 'method': 'GET', 'root_path': '', 'path': '/[object Module]', 'raw_path': b'/[object%20Module]', 'query_string': b'', 'headers': '<...>'}
TRACE:    127.0.0.1:44588 - ASGI [10] Send {'type': 'http.response.start', 'status': 404, 'headers': '<...>'}
INFO:     127.0.0.1:44588 - "GET /%5Bobject%20Module%5D HTTP/1.1" 404 Not Found

Thanks a lot,

Just checked, and I’ve got the same issue even if I expand a GET, PUT or DELETE resource. Let say that I click on this item to expand it, I’ll get the log : image

INFO: <IP>:51426 - "GET /%5Bobject%20Module%5D HTTP/1.1" 404 Not Found

Same thing if I do it on a POST item : image

INFO: <IP>:51504 - "GET /%5Bobject%20Module%5D HTTP/1.1" 404 Not Found

I have the issue whatever the route and associated method I expand. But if it has been expanded/loaded 1 time, I will never get the issue for it if I collapse/expand it, until I refresh the page (Which is quite obvious as content as been loaded…)

It also returns a 404 response when passing url as a path parameter.

from fastapi import APIRouter
from .models import OpenGraphMetaTags

router = APIRouter()

@router.get(
    path='/opengraph-metatags/{url}',
    response_model=OpenGraphMetaTags,
    response_model_by_alias=True,
    response_model_exclude_none=True,
)
async def parse_metatags(url: str):
    ...

Above code works if path paremeter is a plain string eg. some-string, but not for something like https://facebook.com. Terminal logs show that the request url is

INFO: 127.0.0.1:59924 - "GET /opengraph-metatags/https%3A//facebook.com HTTP/1.1" 404 Not Found

It fails to encode the slashes. On swagger I have the following data, tho Screenshot from 2021-11-23 13-59-56

I hope this gets fix soon. I really love FastAPI

Hi, Welcome to FastAPI

please follow the Issue instruction. we need more information to help you. thanks.