Skip to content

0.86.1: worker download errors + flet-mcp get_api improvements#6680

Merged
FeodorFitsner merged 5 commits into
mainfrom
feature/worker-package-download-errors
Jul 15, 2026
Merged

0.86.1: worker download errors + flet-mcp get_api improvements#6680
FeodorFitsner merged 5 commits into
mainfrom
feature/worker-package-download-errors

Conversation

@FeodorFitsner

@FeodorFitsner FeodorFitsner commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Problem

In the Pyodide web worker boot script, pyfetch(app_package_url) is piped straight into unpack_archive() with no status check. Any non-2xx response — a transient server 500, an expired-session 401, a deleted-app 404 — writes the JSON/HTML error body to a temp file, and the user sees:

PythonError: ...
shutil.ReadError: /tmp/tmpycr3w96lpackage.zip?v=0.0 is not a zip file

Observed in production on Flet Studio: intermittent truncated R2 reads caused 500s on package.zip, and every one surfaced as this unreadable traceback (see flet-dev/flet-app#43 for the server-side retry addressing that specific trigger).

Fix

Check response.ok after the fetch and raise a readable error instead:

RuntimeError: Failed to download app package: HTTP 500 <url> — {"detail":...}

including the first 200 chars of the error body (best-effort — body read failures are swallowed).

FetchResponse.ok / .status / .text() verified present in the Pyodide v314.0.2 stdlib. The embedded Python compiles with top-level-await enabled and contains no ${ sequences that JS template interpolation would eat; the JS parses cleanly.

Changes

  • client/web/python-worker.js and sdk/python/templates/build/{{cookiecutter.out_dir}}/web/python-worker.js — same change, kept byte-identical
  • Release prep for 0.86.1: root CHANGELOG.md entry, packages/flet version bump + coordination changelog note

Also in this PR: flet-mcp get_api improvements

Driven by analysis of production agent traces (Flet Studio), two get_api refinements that remove wasted agent round-trips:

  1. Top-level callables are now indexed. get_api("run"), ("use_state"), ("component"), ("memo"), ("observable") and the other hooks/decorators previously returned not found because the API builder only indexed classes. A new functions bucket extracts each package's re-exported public callables (entry point, reactive hooks, decorators) and renders them with a signature: line.
  2. Enum member/query resolve inline. get_api("Colors", query="RED") now returns the matching members instead of erroring with a redirect to search_enum_members.

data/api.json is a gitignored build artifact, so the new bucket ships on the next flet-mcp build. CHANGELOG.md (0.86.1 → Improvements), get_api docstrings, and tests updated (42 passing).

Summary by Sourcery

Improve error handling for app package downloads in the Pyodide web worker and prepare the 0.86.1 release.

Bug Fixes:

  • Add a readable runtime error when the app package download in the Pyodide web worker returns a non-2xx response instead of failing later with a cryptic archive ReadError.

Enhancements:

  • Apply the improved app package download error handling to both the web client worker script and the Python build template to keep them in sync.

Build:

  • Bump the flet Dart package version to 0.86.1 for coordinated release with the web client changes.

Documentation:

  • Document the 0.86.1 bug fix and release details in the root changelog and the Dart package changelog.

pyfetch(app_package_url) was piped straight into unpack_archive
without a status check, so any non-2xx response (transient 500,
expired auth 401, deleted app 404) wrote the JSON/HTML error body
to a temp file and surfaced as a cryptic
"shutil.ReadError: ...package.zip?v=0.0 is not a zip file".

Check response.ok and raise
"Failed to download app package: HTTP <status> <url> - <body>"
with the first 200 chars of the error body.

Applied to both the Flet client (client/web) and the flet build
cookiecutter template.

@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 ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 15, 2026

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: e47985d
Status: ✅  Deploy successful!
Preview URL: https://01356dfc.flet-website-v2.pages.dev
Branch Preview URL: https://feature-worker-package-downl.flet-website-v2.pages.dev

View logs

…get_api

Two improvements driven by production agent-trace analysis:

1. Enum member/query inline. get_api(name, member=/query=) on an enum used to
   return an error redirecting to search_enum_members, costing a round-trip --
   traces showed models burning one call per color on get_api('Colors',
   query='RED'). It now resolves to a ranked member search inline and renders
   the matches; a no-match result points at search_enum_members.

2. Index top-level callables. get_api('run'), ('use_state'), ('component'),
   ('memo'), ('observable') and the other hooks/decorators previously returned
   'not found' because the builder only indexed classes. Add a functions
   bucket: the builder now extracts each package's re-exported public callables
   (entry point, reactive hooks, decorators), the store serves them, and
   render_text emits a signature line.

api.json is a gitignored build artifact, so the new bucket ships on the next
flet-mcp build. Tests + docstrings updated (42 passing).
@FeodorFitsner FeodorFitsner changed the title 0.86.1: Readable error when app package download fails in web worker 0.86.1: worker download errors + flet-mcp get_api improvements Jul 15, 2026
@FeodorFitsner FeodorFitsner merged commit 2522e1d into main Jul 15, 2026
94 of 174 checks passed
@FeodorFitsner FeodorFitsner deleted the feature/worker-package-download-errors branch July 15, 2026 15:40
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