fix(terminal): avoid lazy-loading tool manifest in async websocket handler

The container-user resolver introduced in 9f72093 accessed
'tool_type.manifest', which triggers a SQLAlchemy lazy load inside the
async WebSocket coroutine and raises MissingGreenlet. Fetch the manifest
explicitly with db_session.get() instead, matching the pattern used in
instance_service.py.

- Replace relationship access with explicit async loads in
  _resolve_container_user().
- Add unit tests covering manifest, base-definition, legacy, and missing
  manifest cases.
- Update project map artifacts.

Quality gates: pytest tests/api tests/services/test_terminal_manager_multi.py tests/unit (247 passed), ruff check (clean).
This commit is contained in:
2026-06-19 11:48:41 +02:00
parent 19f91c085e
commit b32fea671f
18 changed files with 298 additions and 101 deletions
+7 -2
View File
@@ -2,12 +2,14 @@
dir: apps/api/tests/unit
## role
Contains unit tests for core API services and utilities, covering database migrations, configuration, Docker operations, Git integration, event handling, file management, health monitoring, manifest compilation, notifications, permissions, SSH keys, and terminal sessions.
Unit test suite for the API backend, covering configuration, Docker services, Git operations, event bus, file/SSH/terminal utilities, monitoring, notifications, and manifest compilation.
## parent
index: apps/api/tests/.pi-map.index.md
map: apps/api/tests/.pi-map.md
## children
-
- apps/api/tests/unit/.ruff_cache
index: apps/api/tests/unit/.ruff_cache/.pi-map.index.md
map: apps/api/tests/unit/.ruff_cache/.pi-map.md
## files
- __init__.py
- test_alembic_migrations.py
@@ -32,6 +34,7 @@ map: apps/api/tests/.pi-map.md
- test_permission_fixer.py
- test_readiness_probe.py
- test_ssh_keys.py
- test_terminal_container_user.py
- test_terminal_session.py
## links
index: apps/api/tests/unit/.pi-map.index.md
@@ -41,5 +44,7 @@ map: apps/api/tests/unit/.pi-map.md
read: __init__.py, test_alembic_migrations.py, test_config.py
- change unit config
read: test_config.py, test_config_profile_resolver.py
- explore unit subdirectories
index: apps/api/tests/unit/.ruff_cache/.pi-map.index.md
## dirty
-