fix(lora-manager): sanitize header limit overrides

This commit is contained in:
pixelpaws
2025-10-23 11:13:31 +08:00
parent 13433f8cd2
commit 3244a5f1a1
4 changed files with 55 additions and 2 deletions

View File

@@ -33,6 +33,7 @@ class _DummyWSManager:
async def test_lora_manager_lifecycle(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
app = web.Application()
app._handler_args = {"max_field_size": 1024, "foo": "bar"}
monkeypatch.setattr(lora_manager.PromptServer, "instance", SimpleNamespace(app=app))
added_static_routes: list[tuple[str, Path]] = []
@@ -174,6 +175,9 @@ async def test_lora_manager_lifecycle(monkeypatch: pytest.MonkeyPatch, tmp_path:
lora_manager.LoraManager.add_routes()
assert lora_manager.LoraManager._cleanup in app.on_shutdown
assert app.on_startup, "startup hooks should be registered"
assert app._handler_args["max_field_size"] == lora_manager.HEADER_SIZE_LIMIT
assert app._handler_args["max_line_size"] == lora_manager.HEADER_SIZE_LIMIT
assert app._handler_args["foo"] == "bar"
assert register_calls == [True]
assert model_factory_calls == [app]
assert stats_setup == [app]

View File

@@ -84,6 +84,15 @@ async def test_standalone_server_sets_up_routes(tmp_path, standalone_module):
assert server.app.on_shutdown, "shutdown callbacks must be attached"
def test_standalone_server_raises_header_limits(standalone_module):
"""``StandaloneServer`` configures ``handler_args`` to tolerate large headers."""
server = standalone_module.StandaloneServer()
assert server.app._handler_args["max_field_size"] == standalone_module.HEADER_SIZE_LIMIT
assert server.app._handler_args["max_line_size"] == standalone_module.HEADER_SIZE_LIMIT
def test_validate_settings_warns_for_missing_model_paths(caplog, standalone_module):
"""Missing model folders trigger the configuration warning."""