Repository navigation
fix(plugin): answer /api/v1/appplugin with the requested products only - #288
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the requested-product filtering change.
No open issues 🎉
What changed in this PR
This PR updates /api/v1/appplugin to return requested products when matches exist, preventing the Android app from installing an unrelated catalog entry.
Changes:
- Parses product IDs from JSON bodies and repeated or comma-separated form fields.
- Filters both snapshot and fallback catalogs, preserving full-list responses when IDs are absent or unmatched.
- Adds tests for request parsing, filtering, fallback behavior, and proxied plugin URLs.
| File | Description |
|---|---|
| tests/test_plugin_routes.py | Adds coverage for product filtering and full-list fallback behavior. |
| src/roborock_local_server/bundled_backend/https_server/routes/api/v1/appplugin.py | Parses requested product IDs and filters catalog records before proxying URLs. |
Review effort: Balanced
There was a problem hiding this comment.
Automated review: passed (nits)
Now that this has passed the automated review, I'll do a human review and then either request changes or merge it.
Checked:
- Request body: confirmed. python-roborock sends
{"apilevel", "productids": [id], "type": 2}as JSON and readsdata[0]["url"](roborock/web_api.py:794-801). The server stores JSON bodies under__json, so your JSON branch is the one the app hits. - Cloud filters by product id: confirmed indirectly. python-roborock asks for one id and takes the first record, which only works if the cloud returns just that product.
- "App installs the first record without checking": partly contradicted.
- The background plugin updater in the APK does check
Product.getIntId() == PluginVersion.getProductid()andapilevel >= 10028. - The device-open install path isn't in the decompiled sources, so your crash log is the only evidence for that path.
- Filtering is correct either way.
- The background plugin updater in the APK does check
- a307 needs an override entry: confirmed by the code. Its product id is a string, so without an override it hashes to an id that can never match, unless a cloud import exists (#224).
Conflict with #224: both PRs rewrite appplugin.build(). Resolving it as "pick the iOS catalog first, then filter by productids" passes all 494 tests, so please rebase onto #224 once it lands.
Nits:
- When ids are sent but none match, the route returns the full catalog, which is exactly the case that crashed the a307 (it gets the a87 zip first). Returning
[]for "ids sent, none matched" is more faithful and fails cleanly. Keep the full list only for "no ids sent", and update theunknown_idcase intest_app_plugin_answers_full_list_without_matching_product_ids. - With a cloud snapshot present, only snapshot records are searched, so a device added after the import never reaches its
APPPLUGIN_LISTentry. - Please add a test for iOS (
type: 1) combined withproductidsin the rebase.
This is an automated review by Claude Code, checked against the decompiled Roborock app (APK + device plugin bundles), python-roborock and a vacuum firmware dump. It can be incorrect, so please reply if any finding looks wrong.
|
Hey @Hoeze this has some conflicts, can you fix it? |
The Android app (4.60.06) posts {"apilevel": 10046, "productids": [id],
"type": 2} as JSON. It installs the first record of the answer and does
not check its productid. The route ignored the requested ids and always
answered the whole catalog. Without a cloud snapshot, every model then
got the a87 plugin, and other models failed to load it.
The route now keeps only the records whose productid is in the request's
productids. It reads the ids from the JSON body and from form fields.
Without ids, or when no record matches, it answers the full list as
before. The filter also applies to a cloud snapshot catalog.
With a cloud snapshot present, the route only searched the snapshot records. A device added after the snapshot import then never got its built-in APPPLUGIN_LIST record. Each requested id now uses the snapshot records if the snapshot has that id, and the built-in records otherwise.
If the request sent product ids and neither the snapshot nor the built-in list had them, the route answered the full list. The app then installed its first record, which is the plugin of another model (the a87 plugin for an a307), and crashed when it opened the device. The route now answers an empty list in that case and keeps the full list for requests without ids.
The route picks the iOS catalog for type 1 requests and then keeps only the requested product ids. The new tests check that an iOS request gets the iOS record of the requested id, and the full iOS list without ids. An id that only the Android catalog has gets the built-in record or nothing, and an unmatched id gets an empty list.
78a20db to
0775e38
Compare
|
Thanks for the review and the approval. I rebased onto main, which fixes the conflicts, and pushed these review changes:
One limit of the built-in fallback: On the first record: yes, my crash came from opening the device. I changed the description and the code comment to say that opening a device installs the first record without the check, while the background updater does check the product id. |
Lash-L
left a comment
There was a problem hiding this comment.
Automated review: passed (re-review at 0775e38c, rebased onto #224)
Now that this has passed the automated review, I'll do a human review and then either request changes or merge it.
Earlier nits:
| Nit | Status |
|---|---|
| Ids that matched nothing returned the full catalog | Fixed: they now get []. A missing, null or empty productids still gets the full list. How the app treats [] is unverifiable, since its caller isn't in the decompiled sources. |
With a snapshot present, a device added later never reached APPPLUGIN_LIST |
Fixed. Built-in records fill in missing ids, and a snapshot record wins over a built-in one with the same id. |
No iOS + productids test |
Fixed: four iOS tests added. |
How it combines with #224:
- The catalog order is right: iOS snapshot → Android snapshot → built-in, then the
productidsfilter. - Requests without ids behave as on
main, on both platforms.
Minor, not blocking:
- On iOS, an id missing from the iOS catalog falls back to an Android zip (the code comment says so).
- A form-encoded iOS request is treated as Android. That comes from #224, and the app sends JSON.
Checks: 515 tests passed, and it merges cleanly. #295 is stacked on this PR, so this one should merge first.
This is an automated review by Claude Code, checked against the decompiled Roborock app (APK + device plugin bundles, refreshed 2026-11-21), python-roborock and a vacuum firmware dump. It can be incorrect, so please reply if any finding looks wrong.
What does this PR do?
/api/v1/apppluginnow answers only the records whoseproductidthe app asked for. Before, it always answered the whole catalog. When the Android app opens a device, it installs the first record of that answer. So on a server without a cloud import, every device got the plugin of the first fallback entry, the a87.Problem
The Android app (4.60.06) posts this body as JSON:
{"apilevel": 10046, "productids": [263], "type": 2}When the app opens a device, it installs the first record of the answer and does not check its
productid. The app's background plugin updater does check it. The route ignoredproductidsand answered the full list. Without a cloud import, that list isAPPPLUGIN_LIST, and its first entry is the a87 plugin (productid 110). A device of another model then gets the a87 zip, and the app crashes when it opens the device:A cloud snapshot with several products has the same problem, because every device gets the first record.
Change
productidsfrom the JSON body (__json) and from form fields, including repeated fields and comma-joined ids.type: 1, else the Android one.APPPLUGIN_LIST. So a device added after the cloud import still gets its plugin.[]. This includes ids that are not valid product ids. Without ids, it answers the full list as before.This alone does not help a model that the catalog lacks. Such a model now gets
[]instead of another model's plugin. My a307 (Saros 20 Flow, product id 263) also needed its entry inMODEL_PRODUCT_ID_OVERRIDESandAPPPLUGIN_LIST. I'll send that as a separate PR, on top of the product id handling of #224.Related
This PR is rebased onto #224.
APPPLUGIN_LISTis the same for both platforms, so an iOS request for an id that no snapshot catalog has gets an Android zip. #224's fallback to the Android catalog has the same limit when the snapshot has no iOS catalog.Before you open this PR (optional, but very helpful)
PRs I reviewed:
Proof that it works
Tested on:
roborock.vacuum.a307)02.17.50a307-pluginbranch. That build is upstream main 32608dd plus the first commit of this PR, the a307 catalog entry, feat(api): enable scene tiles via productTags and category cardSpec #208 and my other fixes for the a307. The tests ran on this branch, on upstream main 2069fc7.What I did and what happened:
Before: opening the a307 in the app crashed with the error above, because the app had installed the a87 plugin.
After: the app installs the a307 plugin and opens the device. The review commits came later and are not deployed. They change only the answers for a snapshot without the requested id, for ids without any match and for iOS. My server has no snapshot, its a307 has a match, and I use Android.
Tests:
tests/test_plugin_routes.pyfailed before the change and pass after it. They cover the JSON and form bodies, the per-id snapshot and built-in lookup, the full list without ids, and[]for ids without a match, with and without a snapshot, and iOS requests with ids.uv run --extra dev pytest -qpasses (515 tests).Screenshots (required for any UI change)
No UI changes.