Skip to content

Fix Postgres CI key-store test when DATABASE_URL is set - #23

Open
dmitryflynn wants to merge 1 commit into
mainfrom
cursor/postgres-ci-debug-0a80
Open

dmitryflynn wants to merge 1 commit into
mainfrom
cursor/postgres-ci-debug-0a80

Conversation

@dmitryflynn

Copy link
Copy Markdown
Owner

Bug

The Postgres integration (live DB) CI job has been red on main and on open PRs. Runtime evidence:

test_db.py::test_api_key_store_in_memory_without_db
AssertionError: isinstance(PgApiKeyStore(...), ApiKeyStore) is False

Reproduced locally with NETLOGIC_DATABASE_URL set at import time: the singleton is PgApiKeyStore, which does not subclass ApiKeyStore.

Cause

That job always exports NETLOGIC_DATABASE_URL. api_key_store is built at import. The test assumed the singleton was still in-memory.

Fix

Clear the env, then assert _build_api_key_store() returns ApiKeyStore. The Postgres-selected singleton is covered by test_api_key_store_selects_postgres_when_enabled.

Verification

With NETLOGIC_DATABASE_URL set: import singleton is PgApiKeyStore; after pop, builder returns ApiKeyStore.

Open in Web Open in Cursor 

…gleton.

The live Postgres job sets NETLOGIC_DATABASE_URL before pytest imports
api_keys, so api_key_store is already PgApiKeyStore. Assert the builder
after clearing the env instead.

Co-authored-by: dmitryflynn <dmitryflynn@users.noreply.github.com>
@dmitryflynn
dmitryflynn marked this pull request as ready for review August 27, 2026 20:01
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.

2 participants