Skip to content

Python: [Bug]: lab lightning tests hard-fail on fastapi 0.141 (litellm proxy imports removed get_flat_dependant) #8057

Description

Description

Python - Lab Tests fails on every PR since fastapi was raised to 0.141. The failing step is Run resource-intensive lab tests:

cd packages/lab && uv run pytest -m "resource_intensive and not integration"
FAILED lightning/tests/test_lightning.py::test_observability - ImportError: cannot import name
'get_flat_dependant' from 'fastapi.dependencies.utils'

This is not specific to any one PR — it reproduces on the merge-queue run for an unrelated ag-ui change and on other open PRs.

Two things combine to produce the failure.

1. fastapi 0.141 no longer exposes get_flat_dependant, and litellm's proxy imports it. The import chain from the test is:

pytest.importorskip("agentlightning")
  -> agentlightning/__init__.py:13   from .llm_proxy import *
  -> agentlightning/llm_proxy.py:41  from litellm.proxy.proxy_server import app, save_worker_config
  -> litellm/proxy/proxy_server.py:397
  -> litellm/proxy/management_endpoints/management_v1/common.py:6
       from fastapi.dependencies.utils import get_flat_dependant   # ImportError

Resolved versions in python/uv.lock: fastapi 0.141.1, litellm 1.95.0, agentlightning 0.3.0.

#8052 raised the bound to fastapi>=0.121.0,<0.142.0, which allows 0.141. That was the right fix for #8042 (the previous <0.140.0 cap excluded every current release); the lab package's transitive litellm[proxy] just is not compatible with 0.141 yet.

2. The importorskip guard no longer skips, so it hard-fails. lightning/tests/test_lightning.py:129 is:

pytest.importorskip("agentlightning")

The repo pins pytest==9.1.1, whose importorskip defaults to exc_type=ModuleNotFoundError. agentlightning is installed, so the failure is a plain nested ImportError from a dependency — which propagates instead of being converted to a skip. The guard was presumably written expecting the older behaviour where any ImportError skipped.

So even once the version conflict is resolved, the guard as written will hard-fail the suite for any future broken transitive import rather than skipping the optional test.

Code Sample

cd python/packages/lab && uv run pytest -m "resource_intensive and not integration"

Error Messages / Stack Traces

lightning/tests/test_lightning.py:129: in test_observability
    pytest.importorskip("agentlightning")
.venv/lib/python3.13/site-packages/agentlightning/__init__.py:13: in <module>
    from .llm_proxy import *
.venv/lib/python3.13/site-packages/agentlightning/llm_proxy.py:41: in <module>
    from litellm.proxy.proxy_server import app, save_worker_config
.venv/lib/python3.13/site-packages/litellm/proxy/proxy_server.py:397: in <module>
    from litellm.proxy.management_endpoints.management_v1 import (
.venv/lib/python3.13/site-packages/litellm/proxy/management_endpoints/management_v1/common.py:6: in <module>
    from fastapi.dependencies.utils import get_flat_dependant
E   ImportError: cannot import name 'get_flat_dependant' from 'fastapi.dependencies.utils'

Package Versions

main @ 1f01b0d. fastapi 0.141.1, litellm 1.95.0, agentlightning 0.3.0, pytest 9.1.1.

Python Version

3.13 (observed on Python Lab Tests (3.13, ubuntu-latest)); the incompatibility is version-independent.

Additional Context

Possible directions, in rough order of how targeted they are — happy to send a PR for whichever you prefer, or to leave it entirely if this is already in hand:

  1. Make the guard skip again: pytest.importorskip("agentlightning", exc_type=ImportError). Restores the test's intended optionality and stops an optional extra's transitive breakage from failing CI. Does not address the underlying incompatibility.
  2. Constrain fastapi for the lab package only, so packages/lab resolves a fastapi that litellm's proxy supports, leaving the raised bound from Python: support current FastAPI releases #8052 in place for the shipped packages.
  3. Wait for / require a litellm release compatible with fastapi 0.141 and bump the floor once one exists.

(1) and (2)/(3) are complementary rather than alternatives: (1) makes the suite honest about the test being optional, while (2)/(3) actually restore the coverage.

I have not opened a PR for this — flagging it first since #8052 is recent and you may already have a preferred direction.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)pythonUsage: [Issues, PRs], Target: PythontriageUsage: [Issues], Target: All issues that still need to be triaged

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions