Skip to content

DM-55493: cap fastapi below 0.140 (faststream incompatibility) - #299

Merged
jonathansick merged 1 commit into
mainfrom
tickets/DM-55493
Jul 27, 2026
Merged

DM-55493: cap fastapi below 0.140 (faststream incompatibility)#299
jonathansick merged 1 commit into
mainfrom
tickets/DM-55493

Conversation

@jonathansick

Copy link
Copy Markdown
Member

Cap FastAPI at <0.140 in [project] dependencies so a future make update cannot silently bake a broken FastAPI into the lockfile.

Why

FastAPI 0.140.0 (2026-07-24, fastapi/fastapi#16049 "Reduce memory usage in dependencies") changed Dependant to @dataclass(slots=True). FastStream's FastAPI plugin monkey-patches dependant.model, .custom_fields and .flat_params onto that instance (faststream/_internal/fastapi/get_dependant.py:131,135,136), which now raises:

AttributeError: 'Dependant' object has no attribute 'model' and no __dict__ for setting new attributes

Upstream bug: ag2ai/faststream#2959 — open and unfixed on main (note the repo moved from airtai/ to ag2ai/). faststream 0.7.2 is the latest release and is still broken; downgrading does not help either, since 0.6.7 carries the same patch.

Ook depends on FastStream both directly (faststream[kafka]) and via safir[db,kafka].

Impact today

The committed uv.lock still pins a pre-break FastAPI (0.139.2), so production and per-PR CI are green. Only the scheduled Periodic CI job — which resolves dependencies unpinned — is red. This PR is preventative: without the cap, the next make update would resolve to 0.140.x and ship a broken image.

Changes

  • pyproject.toml: "fastapi" -> "fastapi<0.140", with a # TODO: remove when ag2ai/faststream#2959 is fixed comment.

  • uv.lock: relocked with plain uv lock (deliberately not --upgrade). The only change is the constraint metadata:

    -    { name = "fastapi" },
    +    { name = "fastapi", specifier = "<0.140" },

    The resolved fastapi version is unchanged at 0.139.2. No other package moved.

  • Changelog fragment under changelog.d/.

Testing

nox -s typing test passes locally:

  • typing: mypy clean — "Success: no issues found in 202 source files".
  • test: 451 passed, 1 skipped in 464.61s.

Note this run exercises the locked FastAPI 0.139.2, so it confirms the cap breaks nothing — it does not itself reproduce the 0.140 failure.

Follow-up

Remove the cap once ag2ai/faststream#2959 ships a fix.

FastAPI 0.140 made Dependant a slotted dataclass, which breaks
FastStream's FastAPI plugin (it monkey-patches model, custom_fields and
flat_params onto the instance). Upstream bug ag2ai/faststream#2959 is
still open, so cap fastapi until it is fixed.

The lockfile already resolved fastapi 0.139.2; relocking with plain
'uv lock' records the constraint without moving any package.
@jonathansick
jonathansick merged commit f8a1e87 into main Jul 27, 2026
7 checks passed
@jonathansick
jonathansick deleted the tickets/DM-55493 branch July 27, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant