Skip to content

fix(plugins): a malformed blocklist refresh keeps the last good list - #1569

Merged
Mavrick-F merged 9 commits into
opengeos:mainfrom
Mavrick-F:fix/plugin-blocklist-shape
Nov 8, 2026
Merged

Mavrick-F merged 9 commits into
opengeos:mainfrom
Mavrick-F:fix/plugin-blocklist-shape

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Summary

The plugin blocklist is how the hosted registry withdraws a plugin: a listed plugin is turned off and can't be loaded or installed again. registry::parse_blocklist read any JSON that wasn't an array, or an object with a blocked array, as an empty list, and so did a list whose entries had no id. A refresh that received {}, {"blocked": {}} or {"blocked": [{}]} cleared every withdrawal. For the hosted registry, store::save_blocklist also wrote that body over the cached blocklist.json, so a later start began with no withdrawals too.

  • A blocklist of the wrong shape is an error: anything other than an array or an object whose blocked is an array, any entry whose id isn't a plugin id, and any entry whose sha256, when given, isn't a SHA-256 hash (either would match nothing). No sha256, or null, still withdraws every version. A refused entry is named by its position, and its reason is cut short, since it can quote what the network sent. save_blocklist parses before it writes or applies anything, so on an error the list in force and the cached file both stay as they were. That matches what already happens when the blocklist can't be fetched.
  • Only an explicitly empty list clears withdrawals: [] or {"blocked": []}.
  • One bad entry refuses the whole refresh instead of being skipped. Skipping would let a corrupted list drop withdrawals silently. Unknown fields in an entry are still ignored, so a later blocklist that adds fields to entries still reads.
  • A list of more than 100,000 entries is refused instead of being cut short, so withdrawals past the cap aren't lost and a bad entry past it isn't skipped.
  • A refused blocklist is reported: plugin.registry and plugin.installFromRegistry (fetch_registry) and the Plugin Manager warn that the blocklist couldn't be read, with the reason, and that the last blocklist read, if any, stays in force. Before, the callers dropped the error. They warn the same way when the hosted registry's blocklist can't be downloaded. The hosted registry always publishes one. Another registry may have none (it blocks nothing), so its failed download stays quiet.
  • A refreshed blocklist that isn't text is refused the same way, rather than read with its bad bytes replaced (an id holding one would match nothing).
  • plugin.registry and plugin.installFromRegistry say which plugins a newly withdrawn list turned off, in one notice, as the Plugin Manager already did.
  • A cached blocklist that can't be read at start is reported: one that isn't text, or one saved by an older version that this parser refuses, goes into load_installed's errors, which the app shows and the command line prints, rather than being ignored. Until the next fetch, no withdrawals apply from such a cache, where the good part of it used to. In Python, rustgis.load_plugins() returns this report. Session(plugins=True) still discards what it returns, as it does for every plugin load error.

Testing

  • blocked_plugins_are_unloaded_and_refused now also feeds the hosted registry's save_blocklist {}, {"blocked": {}}, {"blocked": null}, 1, an entry without an id, [1], a good entry followed by a bad one, a sha256 that isn't a hash, and an id that isn't a plugin id (two forms). Each one is refused, and the withdrawn plugin stays blocked. On main, {} succeeds and clears the list. [] and {"blocked": []} still read as empty lists.
  • New test cached_blocklist_survives_refused_refreshes: refused refreshes leave the cached hosted blocklist byte for byte, and a cache that can't be read is reported by load_installed.
  • registries_and_blocklists_are_read_defensively: a list of exactly 100,000 entries reads whole, and one more is refused. A very long id, or a very long string where an entry should be, gives a short error.
  • New engine test unreadable_plugin_blocklist_warns: plugin.registry against a local registry warns once when its blocklist is {"blocked": {}}, naming the blocklist and the reason, and says nothing when it is {"blocked": []}. The notice is a warning. It also checks that a blocklist that isn't text is refused with a warning, and that one withdrawing a loaded plugin names it in a notice and unloads it.
  • cargo clippy -p rustgis-plugins -p rustgis-engine -p rustgis-ui-egui --all-targets -- -D warnings, cargo test -p rustgis-plugins
  • cargo xtask ci, the wasm32-unknown-unknown build of rustgis-web, and the pre-commit hooks, on 9bf272e.

Related issue

None: found while reviewing the plugin registry code.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Plugin restrictions remain in effect when a blocklist refresh fails, rather than being cleared.
    • Invalid blocklists—including malformed data, unsupported formats, oversized lists, invalid entries, and non-text content—are rejected instead of being treated as empty or partially applied. Invalid cached blocklists and cache read errors are reported at startup.
    • An explicitly empty blocklist still clears existing restrictions.
    • Warnings explain when the last successfully read blocklist remains in force after parsing, saving, or text-decoding failures, and after fetch failures for the default registry. Fetch failures for other registries remain silent.

Loading
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