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:
+10
-10
@@ -4,19 +4,19 @@ dir: apps/api
|
||||
index: apps/api/.pi-map.index.md
|
||||
|
||||
## role
|
||||
FastAPI backend API that manages projects, git repositories, development tools, and tool instances via Docker Compose
|
||||
Backend API server for the Headquarter platform, providing self-hosted project management, git repository orchestration, and development tool integration.
|
||||
## files
|
||||
- .dockerignore | Specifies files and directories to exclude from Docker build context to reduce image size and avoid caching unnecessary files | dep: Docker
|
||||
- Dockerfile | Multi-stage Docker build for a Python web application with Docker socket access, database connectivity, and Cloudflare tunnel support | dep: python:3.11-slim, gcc, libpq-dev, docker-ce-cli, docker-compose-plugin, cloudflared, uvicorn, pyproject.toml dependencies
|
||||
- README.md | README documentation for a self-hosted FastAPI backend API that manages projects, git repositories, development tools, and tool instances via Docker Compose | dep: FastAPI, SQLAlchemy, PostgreSQL, asyncpg, Alembic, Docker, Docker Compose, Authentik, uvicorn, pytest, ruff, mypy
|
||||
- alembic.ini | Configuration file for Alembic database migration tool, specifying script location, database connection URL, and logging settings | dep: alembic, sqlalchemy, asyncpg, postgresql
|
||||
- pyproject.toml | Defines Python project metadata, dependencies, and tool configurations for a FastAPI-based backend API called "headquarter-api" | dep: fastapi, uvicorn, sqlalchemy, asyncpg, alembic, pydantic, pydantic-settings, python-multipart, httpx, structlog, cryptography, pytest, pytest-asyncio, mypy, ruff, aiosqlite
|
||||
- uv.lock | Lock file generated by the uv Python package manager that pins exact dependency versions with cryptographic hashes for reproducible installations | dep: uv, python, pypi, aiosqlite, alembic, annotated-doc, annotated-types, anyio, ast-serialize, asyncpg, mako, sqlalchemy, typing-extensions, idna
|
||||
- wait-for-db.sh | Waits for a PostgreSQL database to become available by polling its TCP port before executing subsequent commands. | dep: nc (netcat), sh (POSIX shell), sleep
|
||||
- .dockerignore | Specifies files and directories to exclude from the Docker build context to optimize image build times and prevent sensitive or unnecessary files from being included.
|
||||
- Dockerfile | Multi-stage Dockerfile that builds and runs a Python application with Docker CLI access, cloudflared, and database readiness checks. | dep: python:3.11-slim, libpq5, git, openssh-client, docker-ce-cli, docker-compose-plugin, cloudflared, uvicorn, netcat-openbsd
|
||||
- README.md | Provides comprehensive documentation for the Headquarter API, a self-hosted platform for managing projects, git repositories, and development tools. | dep: FastAPI, SQLAlchemy, PostgreSQL, asyncpg, Alembic, Docker, Authentik, Pydantic, Ruff, mypy, pytest
|
||||
- alembic.ini | Configuration file for Alembic database migration tool, defining database connection and logging settings. | dep: alembic, sqlalchemy, asyncpg, postgresql
|
||||
- pyproject.toml | Defines project metadata, dependencies, and tool configuration for the Headquarter platform API. | dep: fastapi, uvicorn, sqlalchemy, asyncpg, alembic, pydantic, pydantic-settings, httpx, structlog, cryptography, pytest, mypy, ruff
|
||||
- uv.lock | This file is a UV lockfile that pins exact versions, hashes, and metadata for all Python project dependencies to ensure reproducible environments. | dep: uv, aiosqlite, alembic, annotated-types, anyio, asyncpg, sqlalchemy, mako
|
||||
- wait-for-db.sh | Polls a PostgreSQL host/port until it is available or a retry limit is reached, then executes the passed command. | dep: nc, sleep
|
||||
## arch
|
||||
Containerized Python microservice using FastAPI, SQLAlchemy with Alembic migrations, multi-stage Docker builds, and Docker Compose orchestration with external database dependency
|
||||
Python-based service using FastAPI/ASGI with Alembic for database migrations, multi-stage Docker containerization with cloudflared tunneling, UV for dependency management, and PostgreSQL as the primary datastore with explicit readiness-gated startup orchestration.
|
||||
## tags
|
||||
docker, alembic, python, database, fastapi, sqlalchemy, asyncpg, uvicorn
|
||||
alembic, docker, sqlalchemy, asyncpg, dockerfile, database, postgresql, pydantic
|
||||
## symbols
|
||||
-
|
||||
## workflows
|
||||
|
||||
Reference in New Issue
Block a user