fastapi-utils
fastapi-utils copied to clipboard
[BUG] old_first_parameter = old_parameters[0] IndexError: list index out of range
INFO Using path rest_app\main.py INFO Resolved absolute path C:\Repo\RulesQuestioner\rest_app\main.py INFO Searching for package file structure from directories with init.py files INFO Importing from C:\Repo\RulesQuestioner
╭─ Python package file structure ─╮ │ │ │ 📁 rest_app │ │ ├── 🐍 init.py │ │ └── 🐍 main.py │ │ │ ╰─────────────────────────────────╯
INFO Importing module rest_app.main
╭──────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────╮
│ C:\Users\david\AppData\Local\pypoetry\Cache\virtualenvs\rulesquestioner-c3d_aRDX-py3.11\Lib\site-packages\fastapi │
│ _cli\cli.py:174 in dev │
│ │
│ 171 │ │
│ 172 │ Otherwise, it uses the first [bold]FastAPI[/bold] app found in the imported module o │
│ 173 │ """ │
│ ❱ 174 │ _run( │
│ 175 │ │ path=path, │
│ 176 │ │ host=host, │
│ 177 │ │ port=port, │
│ │
│ ╭──────────────────── locals ─────────────────────╮ │
│ │ app = None │ │
│ │ host = '127.0.0.1' │ │
│ │ path = WindowsPath('rest_app/main.py') │ │
│ │ port = 8002 │ │
│ │ proxy_headers = True │ │
│ │ reload = True │ │
│ │ root_path = '' │ │
│ ╰─────────────────────────────────────────────────╯ │
│ │
│ C:\Users\david\AppData\Local\pypoetry\Cache\virtualenvs\rulesquestioner-c3d_aRDX-py3.11\Lib\site-packages\fastapi │
│ _cli\cli.py:65 in _run │
│ │
│ 62 │ proxy_headers: bool = False, │
│ 63 ) -> None: │
│ 64 │ try: │
│ ❱ 65 │ │ use_uvicorn_app = get_import_string(path=path, app_name=app) │
│ 66 │ except FastAPICLIException as e: │
│ 67 │ │ logger.error(str(e)) │
│ 68 │ │ raise typer.Exit(code=1) from None │
│ │
│ ╭──────────────────── locals ─────────────────────╮ │
│ │ app = None │ │
│ │ command = 'dev' │ │
│ │ host = '127.0.0.1' │ │
│ │ path = WindowsPath('rest_app/main.py') │ │
│ │ port = 8002 │ │
│ │ proxy_headers = True │ │
│ │ reload = True │ │
│ │ root_path = '' │ │
│ │ workers = None │ │
│ ╰─────────────────────────────────────────────────╯ │
│ │
│ C:\Users\david\AppData\Local\pypoetry\Cache\virtualenvs\rulesquestioner-c3d_aRDX-py3.11\Lib\site-packages\fastapi │
│ _cli\discover.py:150 in get_import_string │
│ │
│ 147 │ │ raise FastAPICLIException(f"Path does not exist {path}") │
│ 148 │ mod_data = get_module_data_from_path(path) │
│ 149 │ sys.path.insert(0, str(mod_data.extra_sys_path)) │
│ ❱ 150 │ use_app_name = get_app_name(mod_data=mod_data, app_name=app_name) │
│ 151 │ import_example = Syntax( │
│ 152 │ │ f"from {mod_data.module_import_str} import {use_app_name}", "python" │
│ 153 │ ) │
│ │
│ ╭─────────────────────────────── locals ───────────────────────────────╮ │
│ │ app_name = None │ │
│ │ mod_data = ModuleData( │ │
│ │ │ module_import_str='rest_app.main', │ │
│ │ │ extra_sys_path=WindowsPath('C:/Repo/RulesQuestioner') │ │
│ │ ) │ │
│ │ path = WindowsPath('rest_app/main.py') │ │
│ ╰──────────────────────────────────────────────────────────────────────╯ │
│ │
│ C:\Users\david\AppData\Local\pypoetry\Cache\virtualenvs\rulesquestioner-c3d_aRDX-py3.11\Lib\site-packages\fastapi │
│ cli\discover.py:103 in get_app_name │
│ │
│ 100 │
│ 101 def get_app_name(*, mod_data: ModuleData, app_name: Union[str, None] = None) -> str: │
│ 102 │ try: │
│ ❱ 103 │ │ mod = importlib.import_module(mod_data.module_import_str) │
│ 104 │ except (ImportError, ValueError) as e: │
│ 105 │ │ logger.error(f"Import error: {e}") │
│ 106 │ │ logger.warning( │
│ │
│ ╭─────────────────────────────── locals ───────────────────────────────╮ │
│ │ app_name = None │ │
│ │ mod_data = ModuleData( │ │
│ │ │ module_import_str='rest_app.main', │ │
│ │ │ extra_sys_path=WindowsPath('C:/Repo/RulesQuestioner') │ │
│ │ ) │ │
│ ╰──────────────────────────────────────────────────────────────────────╯ │
│ │
│ C:\Users\david\AppData\Local\Programs\Python\Python311\Lib\importlib_init.py:126 in import_module │
│ │
│ 123 │ │ │ if character != '.': │
│ 124 │ │ │ │ break │
│ 125 │ │ │ level += 1 │
│ ❱ 126 │ return _bootstrap._gcd_import(name[level:], package, level) │
│ 127 │
│ 128 │
│ 129 _RELOADING = {} │
│ │
│ ╭───────── locals ──────────╮ │
│ │ level = 0 │ │
│ │ name = 'rest_app.main' │ │
│ │ package = None │ │
│ ╰───────────────────────────╯ │
│ in _gcd_import:1206 │
│ ╭───────── locals ──────────╮ │
│ │ level = 0 │ │
│ │ name = 'rest_app.main' │ │
│ │ package = None │ │
│ ╰───────────────────────────╯ │
│ in find_and_load:1178 │
│ ╭──────────────────────── locals ────────────────────────╮ │
│ │ import = <function _gcd_import at 0x0000025201813D80> │ │
│ │ module = <object object at 0x0000025201844050> │ │
│ │ name = 'rest_app.main' │ │
│ ╰────────────────────────────────────────────────────────╯ │
│ in find_and_load_unlocked:1149 │
│ ╭─────────────────────────────────────────────────── locals ────────────────────────────────────────────────────╮ │
│ │ child = 'main' │ │
│ │ import = <function _gcd_import at 0x0000025201813D80> │ │
│ │ name = 'rest_app.main' │ │
│ │ parent = 'rest_app' │ │
│ │ parent_module = <module 'rest_app' from 'C:\Repo\RulesQuestioner\rest_app\init.py'> │ │
│ │ parent_spec = ModuleSpec(name='rest_app', loader=<_frozen_importlib_external.SourceFileLoader object at │ │
│ │ 0x0000025206779990>, origin='C:\Repo\RulesQuestioner\rest_app\init.py', │ │
│ │ submodule_search_locations=['C:\Repo\RulesQuestioner\rest_app']) │ │
│ │ path = ['C:\Repo\RulesQuestioner\rest_app'] │ │
│ │ spec = ModuleSpec(name='rest_app.main', loader=<_frozen_importlib_external.SourceFileLoader object │ │
│ │ at 0x0000025206779F90>, origin='C:\Repo\RulesQuestioner\rest_app\main.py') │ │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ in _load_unlocked:690 │
│ ╭─────────────────────────────────────────────────── locals ────────────────────────────────────────────────────╮ │
│ │ module = <module 'rest_app.main' from 'C:\Repo\RulesQuestioner\rest_app\main.py'> │ │
│ │ spec = ModuleSpec(name='rest_app.main', loader=<_frozen_importlib_external.SourceFileLoader object at │ │
│ │ 0x0000025206779F90>, origin='C:\Repo\RulesQuestioner\rest_app\main.py') │ │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ in exec_module:940 │
│ ╭─────────────────────────────────────────────────── locals ────────────────────────────────────────────────────╮ │
│ │ code = <code object nil'+46, │ │ │ │ │ │ │ '__package__': '', │ │ │ │ │ │ │ '__loader__': <class '_frozen_importlib.BuiltinImporter'>, │ │ │ │ │ │ │ '__spec__': ModuleSpec(name='builtins', loader=<class │ │ │ │ '_frozen_importlib.BuiltinImporter'>, origin='built-in'), │ │ │ │ │ │ │ '__build_class__': <built-in function __build_class__>, │ │ │ │ │ │ │ '__import__': <built-in function __import__>, │ │ │ │ │ │ │ 'abs': <built-in function abs>, │ │ │ │ │ │ │ 'all': <built-in function all>, │ │ │ │ │ │ │ 'any': <built-in function any>, │ │ │ │ │ │ │ ... +148 │ │ │ │ │ │ }, │ │ │ │ │ │ 'Depends': <function Depends at 0x0000025206554900>, │ │ │ │ │ │ 'FastAPI': <class 'fastapi.applications.FastAPI'>, │ │ │ │ │ │ ... +2 │ │ │ │ │ } │ │ │ │ ) │ │ │ │ f = <built-in function exec> │ │ │ │ kwds = {} │ │ │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ C:\Repo\RulesQuestioner\rest_app\main.py:4 in <module> │ │ │ │ 1 │ │ 2 from fastapi import Depends, FastAPI │ │ 3 from dependency_injector.wiring import Provide, inject │ │ ❱ 4 from .containers import Application │ │ 5 from .endpoints import document_endpoints │ │ 6 │ │ 7 app = FastAPI() │ │ │ │ ╭──────────────────────── locals ────────────────────────╮ │ │ │ Depends = <function Depends at 0x0000025206554900> │ │ │ │ FastAPI = <class 'fastapi.applications.FastAPI'> │ │ │ │ inject = <function inject at 0x00000252068556C0> │ │ │ │ Provide = <class 'dependency_injector.wiring.Provide'> │ │ │ ╰────────────────────────────────────────────────────────╯ │ │ │ │ C:\Repo\RulesQuestioner\rest_app\containers.py:5 in <module> │ │ │ │ 2 from dependency_injector import containers, providers │ │ 3 from fastapi import APIRouter │ │ 4 from . import services │ │ ❱ 5 from .endpoints import document_endpoints │ │ 6 │ │ 7 class Core(containers.DeclarativeContainer): │ │ 8 │ config = providers.Configuration() │ │ │ │ ╭─────────────────────────────────────────────────── locals ────────────────────────────────────────────────────╮ │ │ │ APIRouter = <class 'fastapi.routing.APIRouter'> │ │ │ │ containers = <module 'dependency_injector.containers' from │ │ │ │ 'C:\\Users\\david\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\rulesquestioner-c3d_aRDX-py3.1… │ │ │ │ logging = <module 'logging' from │ │ │ │ 'C:\\Users\\david\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\logging\\__init__.py'> │ │ │ │ providers = <module 'dependency_injector.providers' from │ │ │ │ 'C:\\Users\\david\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\rulesquestioner-c3d_aRDX-py3.1… │ │ │ │ services = <module 'rest_app.services' from 'C:\\Repo\\RulesQuestioner\\rest_app\\services\\__init__.py'> │ │ │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ C:\Repo\RulesQuestioner\rest_app\endpoints\document_endpoints.py:7 in <module> │ │ │ │ 4 │ │ 5 router = InferringRouter() │ │ 6 │ │ ❱ 7 @cbv(router) │ │ 8 class DocumentEndpoints(BaseEndpoint): │ │ 9 │ def __init__(self) -> None: │ │ 10 │ │ super().__init__() │ │ │ │ ╭────────────────────────────────── locals ──────────────────────────────────╮ │ │ │ BaseEndpoint = <class 'rest_app.endpoints.base_endpoint.BaseEndpoint'> │ │ │ │ cbv = <function cbv at 0x00000252068862A0> │ │ │ │ InferringRouter = <class 'fastapi.routing.APIRouter'> │ │ │ │ router = <fastapi.routing.APIRouter object at 0x000002520686CDD0> │ │ │ ╰────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ C:\Users\david\AppData\Local\pypoetry\Cache\virtualenvs\rulesquestioner-c3d_aRDX-py3.11\Lib\site-packages\fastapi │ │ _restful\cbv.py:46 in decorator │ │ │ │ 43 │ │ │ 44 │ def decorator(cls: Type[T]) -> Type[T]: │ │ 45 │ │ # Define cls as cbv class exclusively when using the decorator │ │ ❱ 46 │ │ return _cbv(router, cls, *urls) │ │ 47 │ │ │ 48 │ return decorator │ │ 49 │ │ │ │ ╭────────────────────────────────── locals ──────────────────────────────────╮ │ │ │ cls = <class 'rest_app.endpoints.document_endpoints.DocumentEndpoints'> │ │ │ │ router = <fastapi.routing.APIRouter object at 0x000002520686CDD0> │ │ │ │ urls = () │ │ │ ╰────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ C:\Users\david\AppData\Local\pypoetry\Cache\virtualenvs\rulesquestioner-c3d_aRDX-py3.11\Lib\site-packages\fastapi │ │ _restful\cbv.py:57 in _cbv │ │ │ │ 54 │ function calls that will properly inject an instance of
cls`. │
│ 55 │ """ │
│ 56 │ _init_cbv(cls, instance) │
│ ❱ 57 │ _register_endpoints(router, cls, *urls) │
│ 58 │ return cls │
│ 59 │
│ 60 │
│ │
│ ╭─────────────────────────────────── locals ───────────────────────────────────╮ │
│ │ cls = <class 'rest_app.endpoints.document_endpoints.DocumentEndpoints'> │ │
│ │ instance = None │ │
│ │ router = <fastapi.routing.APIRouter object at 0x000002520686CDD0> │ │
│ │ urls = () │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ C:\Users\david\AppData\Local\pypoetry\Cache\virtualenvs\rulesquestioner-c3d_aRDX-py3.11\Lib\site-packages\fastapi │
│ _restful\cbv.py:131 in _register_endpoints │
│ │
│ 128 │ for route in cbv_routes: │
│ 129 │ │ router.routes.remove(route) │
│ 130 │ │ route.path = route.path[prefix_length:] │
│ ❱ 131 │ │ _update_cbv_route_endpoint_signature(cls, route) │
│ 132 │ │ route.name = cls.name + "." + route.name │
│ 133 │ │ cbv_router.routes.append(route) │
│ 134 │ router.include_router(cbv_router) │
│ │
│ ╭─────────────────────────────────────────────────── locals ────────────────────────────────────────────────────╮ │
│ │ cbv_router = <fastapi.routing.APIRouter object at 0x00000252063A8110> │ │
│ │ cbv_routes = [APIRoute(path='/documents', name='get_hello_world', methods=['GET'])] │ │
│ │ cls = <class 'rest_app.endpoints.document_endpoints.DocumentEndpoints'> │ │
│ │ function_members = [ │ │
│ │ │ ( │ │
│ │ │ │ 'init', │ │
│ │ │ │ <function _init_cbv.
This issue was reported before and was given an unhelpful response about this repo being dead. The issue is still happening over 2 years later.