Skip to content

test: guard @pg_only fixtures against wiping a remote DB#144

Merged
FlyM1ss merged 1 commit into
mainfrom
fix/pg-fixture-guard
Jul 18, 2026
Merged

test: guard @pg_only fixtures against wiping a remote DB#144
FlyM1ss merged 1 commit into
mainfrom
fix/pg-fixture-guard

Conversation

@FlyM1ss

@FlyM1ss FlyM1ss commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Closes #136.

The @pg_only fixtures DELETE FROM external_agents / agent_versions / strategies / users against whatever TEST_POSTGRES_URL names, and conftest.py deliberately does not strip that var (it is the opt-in for the live tier). CONTENT_DATABASE_URL/USERS_DATABASE_URL are the same prod Neon DB, so export TEST_POSTGRES_URL=$CONTENT_DATABASE_URL && pytest would wipe prod accounts + agents + API keys.

require_local_postgres_url() (new _postgres_testing.py, following the _v2_fakes.py shared-helper convention) allowlists localhost/127.0.0.1/::1 via urlsplit. The four destructive fixtures call it first, so a remote URL now fails loud (red errors) instead of silently wiping prod — or silently skipping.

Tests: 5 unit + 4 fixture-guard integration cases (the latter prove each fixture refuses before touching the network). Suite: 1095 passed, 18 skipped; @pg_only tier still skips cleanly with no TEST_POSTGRES_URL.

Note: protection is per destructive fixture (the four that exist). A future 5th destructive fixture must call the guard too — left as a convention rather than an import-time raise, which this repo's CLAUDE.md warns can abort the whole collection session.

🤖 Generated with Claude Code

The @pg_only fixtures run unconditional `DELETE FROM` against whatever
TEST_POSTGRES_URL names, and conftest.py deliberately does not strip that
var (it is the opt-in for the live tier). So `export
TEST_POSTGRES_URL=$CONTENT_DATABASE_URL` would wipe prod accounts, agents,
and API keys. Add require_local_postgres_url(): the four destructive
fixtures now refuse any non-localhost host, failing loud instead of
silently wiping prod. Closes #136.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agentic-trading-lab Ready Ready Preview, Comment Jul 18, 2026 7:11am

@FlyM1ss
FlyM1ss merged commit aa75286 into main Jul 18, 2026
4 checks passed
@FlyM1ss
FlyM1ss deleted the fix/pg-fixture-guard branch July 18, 2026 07:19
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.

@pg_only fixtures can wipe a real database

1 participant