Repository navigation
fix(marketplace): browser plugin installs were refused — accept the repository id the UI sends - #48
Merged
Conversation
…wser installs were refused)
Reproduced against the live container — the marketplace UI's provenance value
is refused before any network call:
POST /api/plugins/install {"source_repo_id": "1"} -> 400 in ~0.004s
{"error":"… is not published by repository 1 — it is published by: Official fnack Plugins (id 1)"}
POST /api/plugins/install {"source_repo_id": 1 } -> 200 in ~0.39s
The card action embeds the id in an HTML attribute (`installPlugin('id',
'ver', '1')`), so it reaches fetch() as a numeric STRING while
PluginRegistry compares it against integer repository ids — the lookup
misses and the install is refused. Every Install / Update / Switch click in
the Marketplace was affected; only M2M/API calls with an int worked.
- static/app.js: emit the repository id as an unquoted number in the card
action and coerce in installPlugin() before sending it.
- plugins/api.py: accept a numeric string for source_repo_id (defensive, any
client), leaving genuinely invalid values to the registry's real message.
- plugins/api.py: log the refusal reason on install/update, and log
successful installs with their source repo. The gunicorn access log only
recorded "400 <bytes>", which made a failed install impossible to diagnose
after the fact (exactly what happened here).
- tests/architecture/test_marketplace_repo_identity.py: new API-level
regression test — string provenance accepted, int provenance accepted,
unknown repository refused with the real reason, ambiguity still refused
when no provenance is given.
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.
The failure (explained from the live container logs + reproduction)
The access log showed:
A 400, 5 ms, no download attempt. Reproducing it identified a real regression introduced when repo-scoped provenance shipped:
The marketplace card embeds the repository id in an HTML attribute
(
installPlugin('fnack.x', '1.0.0', '1')), so it reachesfetch()as a numeric string, whilePluginRegistrycompares it against integer repo ids — the lookup misses, and the install is refused before any network call. Every Install / Update / Switch click in the Marketplace was affected; only API/M2M callers sending an int worked. The deployed image serves the buggy line (curl -s localhost:4688/static/app.js | grep source_repo_id→const src = e.source_repo_id ? \, '${e.source_repo_id}'` : '';`).Fix
static/app.js: emit the repository id as an unquoted number in the card action, and coerce ininstallPlugin()before sending.plugins/api.py: accept a numeric string forsource_repo_id(defensive for any client), leaving genuinely invalid values to the registry's real message.plugins/api.py: log the refusal reason on install/update (and log successful installs with their source repo). The access log only recorded400 <bytes>, which made this failure impossible to diagnose after the fact.Regression test
tests/architecture/test_marketplace_repo_identity.py::test_install_api_accepts_string_and_int_repo_ids— string provenance accepted, int accepted, unknown repository still refused with the real reason, ambiguity still refused when no provenance is given.Verification
Note
The exact 406-byte body of the original failure is not recoverable (gunicorn logs status + size only). The reproduction above is the deterministic cause for UI clicks; with the new logging, any future refusal prints its reason.