Skip to content

Fix web apps failing to start with FastAPI 0.145+ and prepare 1.0.5 - #6988

Merged
FeodorFitsner merged 3 commits into
mainfrom
prepare-release-1.0.5
Oct 21, 2026
Merged

FeodorFitsner merged 3 commits into
mainfrom
prepare-release-1.0.5

Conversation

@ndonkoHenri

@ndonkoHenri ndonkoHenri commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6984.

FastAPI 0.145 (fastapi/fastapi#16518) removed the deprecated openapi_prefix argument. flet_web.fastapi.FastAPI re-declares FastAPI's constructor signature and forwarded openapi_prefix="" unconditionally, so on any fresh install with 1.0.4 flet run --web, the web browser view and FastAPI-hosted apps crash on startup with:

TypeError: FastAPI.__init__() got an unexpected keyword argument 'openapi_prefix'

Fix

Backport of the flet_fastapi.py change from 77eace0 on flet-1.1.0: the wrapper maps openapi_prefix onto root_path (root_path or openapi_prefix), which is exactly what FastAPI ≤0.144 did internally, so existing callers see no behavior change. The Python 3.15 changes from the same commit are left on 1.1.0.

test_fastapi.py from that commit is included too: it checks the root_path/openapi_prefix precedence and that on_startup/on_shutdown run through the custom lifespan. Since CI resolves dependencies fresh, it runs against the latest FastAPI.

FastAPI 1.0.4 wrapper this PR
0.144.0 pass 4 passed
0.145.0 4 failed (TypeError) 4 passed
0.158.1 (latest) 4 failed (TypeError) 4 passed

Release prep

  • packages/flet/pubspec.yaml → 1.0.5, and the flet entry in client/pubspec.lock (only that line; no other lock changes).
  • ## 1.0.5 sections in CHANGELOG.md and packages/flet/CHANGELOG.md.

After merge, tagging v1.0.5 on main releases it.

Summary by Sourcery

Restore Flet web application startup compatibility with current FastAPI releases and prepare version 1.0.5.

Bug Fixes:

  • Fix Flet web applications failing to start with FastAPI 0.145 and later by preserving compatibility with the removed openapi_prefix argument.

Enhancements:

  • Preserve root_path precedence while maintaining legacy openapi_prefix behavior in the Flet FastAPI wrapper.

Tests:

  • Add coverage for root path compatibility and FastAPI startup and shutdown lifecycle hooks.

Chores:

  • Prepare the 1.0.5 release across package metadata, lockfile, and changelogs.

FastAPI 0.145 removed the deprecated `openapi_prefix` argument, which the
`flet_web.fastapi.FastAPI` wrapper always forwarded, so `flet run --web`,
the web browser view and FastAPI-hosted apps raised a `TypeError` on
startup. The wrapper now maps `openapi_prefix` onto `root_path`, as FastAPI
itself did before removing it (#6984).

Backport of the `flet_fastapi.py` change from 77eace0 on flet-1.1.0.

Bump the flet package to 1.0.5.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 32590a8
Status: ✅  Deploy successful!
Preview URL: https://75976e00.flet-website-v2.pages.dev
Branch Preview URL: https://prepare-release-1-0-5.flet-website-v2.pages.dev

View logs

@FeodorFitsner
FeodorFitsner merged commit 3ec4743 into main Oct 21, 2026
24 of 112 checks passed
@FeodorFitsner
FeodorFitsner deleted the prepare-release-1.0.5 branch October 21, 2026 18:36
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.

bug: flet run --web fails with TypeError: ... unexpected keyword argument 'openapi_prefix' on FastAPI 0.145+

2 participants