0.86.1: worker download errors + flet-mcp get_api improvements#6680
Merged
Conversation
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.
Deploying flet-website-v2 with
|
| 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 |
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In the Pyodide web worker boot script,
pyfetch(app_package_url)is piped straight intounpack_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: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.okafter the fetch and raise a readable error instead: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.jsandsdk/python/templates/build/{{cookiecutter.out_dir}}/web/python-worker.js— same change, kept byte-identicalCHANGELOG.mdentry,packages/fletversion bump + coordination changelog noteAlso in this PR: flet-mcp
get_apiimprovementsDriven by analysis of production agent traces (Flet Studio), two
get_apirefinements that remove wasted agent round-trips:get_api("run"),("use_state"),("component"),("memo"),("observable")and the other hooks/decorators previously returnednot foundbecause the API builder only indexed classes. A newfunctionsbucket extracts each package's re-exported public callables (entry point, reactive hooks, decorators) and renders them with asignature:line.get_api("Colors", query="RED")now returns the matching members instead of erroring with a redirect tosearch_enum_members.data/api.jsonis a gitignored build artifact, so the new bucket ships on the nextflet-mcpbuild.CHANGELOG.md(0.86.1 → Improvements),get_apidocstrings, 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:
Enhancements:
Build:
fletDart package version to 0.86.1 for coordinated release with the web client changes.Documentation: