mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 15:38:19 +08:00
fix(plugin): 修复坏插件模块声明击穿模块调度导致接口大面积报错
- projection 只接受映射类型的 get_module 声明,非法值跳过并记日志 - dispatcher 同步/异步路径防御非映射方法表,单个坏插件被隔离 - media 端点改用 application 层插件运行时门面,消除分层违规依赖 - 图片能力测试打桩 models.dev 目录边界,适配仓库内离线目录留空 Closes #6346
This commit is contained in:
@@ -207,3 +207,30 @@ async def test_async_dispatch_awaits_coroutines_and_offloads_sync_functions() ->
|
||||
|
||||
assert await dispatcher.async_dispatch("execute") == ["plugin", "system"]
|
||||
assert offloaded == [sync_module.execute]
|
||||
|
||||
|
||||
def test_plugin_non_mapping_module_decl_is_reported_and_skipped() -> None:
|
||||
"""插件把方法表声明成 list 时走错误策略,且不影响后续健康插件。"""
|
||||
dispatcher, plugin_error, _, _ = _dispatcher(
|
||||
plugins={
|
||||
("Bad", "坏插件"): ["not-a-mapping"],
|
||||
("Good", "好插件"): {"execute": lambda: "ok"},
|
||||
},
|
||||
)
|
||||
|
||||
assert dispatcher.dispatch("execute") == "ok"
|
||||
plugin_error.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_plugin_non_mapping_module_decl_is_reported_and_skipped() -> None:
|
||||
"""异步路径下坏插件同样被隔离,嵌套补丁场景不再冒泡击穿调度。"""
|
||||
dispatcher, plugin_error, _, _ = _dispatcher(
|
||||
plugins={
|
||||
("Bad", "坏插件"): ["not-a-mapping"],
|
||||
("Good", "好插件"): {"execute": lambda: "ok"},
|
||||
},
|
||||
)
|
||||
|
||||
assert await dispatcher.async_dispatch("execute") == "ok"
|
||||
plugin_error.assert_called_once()
|
||||
|
||||
Reference in New Issue
Block a user