Skip to content

fix(compose): make full stack boot — quote reserved "window" column + ship pydantic[email]#227

Merged
beenuar merged 2 commits into
mainfrom
fix/postgres-window-reserved-keyword
May 28, 2026
Merged

fix(compose): make full stack boot — quote reserved "window" column + ship pydantic[email]#227
beenuar merged 2 commits into
mainfrom
fix/postgres-window-reserved-keyword

Conversation

@beenuar
Copy link
Copy Markdown
Owner

@beenuar beenuar commented May 28, 2026

Summary

The docker compose up — full stack (Compose Smoke) CI job had been chronically red, meaning the product could not actually boot end-to-end. Root-caused and fixed two independent, product-breaking bugs. The full-stack smoke job now passes (first green in a long time).

Bug 1 — Postgres init crash (aisoc-postgres exited (3))

services/api/migrations/041_attack_chains.sql used window (a reserved keyword in Postgres) as an unquoted column name. Postgres refused to run the migration on container init:

ERROR: syntax error at or near "window"

Because migrations are mounted into /docker-entrypoint-initdb.d, this killed the DB container on startup and took the whole stack down.

Fix: quote the identifier as "window" everywhere it is used:

  • column definition, CHECK constraint, and UNIQUE constraint in the migration
  • the raw INSERT ... ON CONFLICT in services/api/app/api/v1/endpoints/attack_chain.py

Bug 2 — API container crash on import (email-validator is not installed)

app/api/v1/endpoints/auth.py uses Pydantic's EmailStr, which requires the optional email-validator package. pydantic was declared without the [email] extra, so neither the Poetry install nor the Dockerfile pip-fallback shipped it. The aisoc-api container crashed on import.

Fix:

  • services/api/pyproject.toml: pydantic = { version = ">=2.7,<2.14", extras = ["email"] }
  • services/api/Dockerfile: pip fallback now installs pydantic[email]>=2.7,<2.14

Test plan

  • docker compose up — full stack CI job passes (5m34s) — previously failing
  • All other CI checks green (Python/Go/TS lint, type-check, tests, builds, CodeQL, OpenAPI verify, compose validate)
  • Local: email_validator importable after pyproject.toml change
  • Local: Postgres init runs 041_attack_chains.sql without syntax error

Note: the security-audit check remains red — this is the pre-existing, accepted failure surfacing transitive-dependency CVEs (langchain/cryptography/starlette/idna + pnpm transitive deps) unrelated to this change. Tracked separately.

Beenu Arora and others added 2 commits May 28, 2026 15:55
Migration 041 declared a column named `window`, which is a reserved
keyword in Postgres. The unquoted identifier caused a syntax error
during `docker-entrypoint-initdb.d` execution, so the postgres
container exited with code 3 and took the whole Compose stack down
(the chronic "Compose Smoke" CI failure).

Quote `"window"` everywhere it is used as an identifier:
  - migrations/041_attack_chains.sql: column def, CHECK, UNIQUE
  - endpoints/attack_chain.py: INSERT column list + ON CONFLICT target

The `:window` bind parameter is unaffected. Verified by running the
full migration set against postgres:16-alpine: init completes with no
errors and the table, constraints, and RLS policy are created.

Co-authored-by: Cursor <cursoragent@cursor.com>
The API imports `EmailStr` in the auth, passkeys, and tenants endpoints.
`EmailStr` requires the optional `email-validator` package, which pydantic
only pulls in through its `email` extra. Because `pyproject.toml` declared
plain `pydantic`, neither the Poetry install nor the Dockerfile pip fallback
shipped `email-validator`, so the container crashed on import with
"email-validator is not installed" — taking down the whole Compose stack.

Declare the extra in both install paths so the API boots.

Co-authored-by: Cursor <cursoragent@cursor.com>
@beenuar beenuar changed the title fix(db): quote reserved keyword "window" in attack_chains migration fix(compose): make full stack boot — quote reserved "window" column + ship pydantic[email] May 28, 2026
@beenuar beenuar merged commit 4a4d017 into main May 28, 2026
25 of 26 checks passed
@beenuar beenuar deleted the fix/postgres-window-reserved-keyword branch May 28, 2026 23:27
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