-
Notifications
You must be signed in to change notification settings - Fork 60
Comparing changes
Open a pull request
base repository: keploy/samples-python
base: main
head repository: keploy/samples-python
compare: add-fastapi-sqlalchemy-pg-catalog
- 10 commits
- 7 files changed
- 1 contributor
Commits on May 11, 2026
-
fastapi-sqlalchemy-pg-catalog: minimal repro sample for keploy/integr…
…ations#193 FastAPI + SQLAlchemy 2.x + psycopg2 + Postgres 13 sample built to exercise the v3 dispatcher's simple-query ClassCatalog branch. The sample's init.sql pre-creates the `project` table so SQLAlchemy's Base.metadata.create_all skips CREATE TABLE at record time -- the shape the dispatcher bug requires. Used by the keploy/integrations Woodpecker lane sqlalchemy-pg-catalog-postgres to assert that recorded `type: query` mocks with `class: CATALOG` are consulted by the simple-query path, not just the extended-query path. Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 61a61e6 - Browse repository at this point
Copy the full SHA 61a61e6View commit details -
fastapi-sqlalchemy-pg-catalog: tighten flow.sh + init.sql per Copilot…
… review flow.sh: - set -Eeuo pipefail so curl/other failures actually fail the script. - Track readiness explicitly; exit 1 with a clear message if the app never reaches /health within READY_TIMEOUT_S (default 60s) instead of silently falling through and proceeding against a dead app. - curl -fsS for the readiness probe and the endpoint calls so HTTP failures propagate as exit codes (the previous `curl -sS ... && echo` shape silenced non-2xx responses). init.sql: - Replace `INSERT ... ON CONFLICT DO NOTHING` with `INSERT ... SELECT WHERE NOT EXISTS`. The model has no UNIQUE constraint on name, so ON CONFLICT had nothing to fire on; this form is genuinely idempotent on re-runs against an existing volume. Refs Copilot review on #102. Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 4becdde - Browse repository at this point
Copy the full SHA 4becddeView commit details
Commits on May 12, 2026
-
fastapi-sqlalchemy-pg-catalog: parameterize README + SQL_ECHO env knob
Addresses two Copilot review nits on #102: * README.md: the local-repro snippet hardcoded `--container-name pg-catalog-repro-app`, but the compose file uses `${APP_CONTAINER:-pg-catalog-repro-app}` so a user who overrides APP_CONTAINER (e.g. to isolate concurrent runs) would have keploy point at a non-existent container. Both keploy invocations now thread `${APP_CONTAINER:-pg-catalog-repro-app}` so they pick up the same env override compose sees. Also switched the deprecated camelCase `--apiTimeout`/`--disableMockUpload` to the kebab forms the v3 CLI actually registers (`--api-timeout`; mock-upload flag dropped — not registered on v3-dev `test`). * main.py: SQL echo was unconditional. It is INTENTIONALLY on by default for this sample (the whole point is to surface SQLAlchemy's pg_class probe + create_all behaviour in the app log so a reader can correlate it with the keploy agent log), but the noise is real for unrelated investigations. Gated behind SQL_ECHO env var with a comment explaining why it's on by default. Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for ec3174e - Browse repository at this point
Copy the full SHA ec3174eView commit details -
fastapi-sqlalchemy-pg-catalog/app: clearer DATABASE_URL error + async…
…-safe create_all Two nits from the Copilot review: * DATABASE_URL: `os.environ["DATABASE_URL"]` raised a bare KeyError at import time, which surfaces as a noisy traceback in container logs with no hint about what's missing. Switched to os.getenv with an explicit RuntimeError that names the env var and gives a sample URL format. * lifespan: `Base.metadata.create_all(engine)` is synchronous psycopg2 I/O running inside an async lifespan, blocking uvicorn's event loop until pg_class probe + any CREATE TABLE round-trips complete. Switched to `await asyncio.to_thread(...)` so the loop stays responsive. For this minimal repro the difference is small, but the pattern is the right FastAPI shape for any startup that touches a sync DB driver. Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 3203a0a - Browse repository at this point
Copy the full SHA 3203a0aView commit details -
fastapi-sqlalchemy-pg-catalog: clarify simple-Query semantics on para…
…meterized SQL Copilot review noted (correctly) that the README + main.py docstring described the pg_class probe as "parameter-less SQL", which conflicts with the recorded mock carrying 7 bind values. psycopg2 in fact uses the simple-Query protocol even when the source SQL is parameterized: it substitutes %(param)s placeholders client-side and emits the resulting inlined SQL as a single Q packet (no Bind/Execute frames). The bind values exist at the application layer; the wire shape is simple-Query. Both docs now say so explicitly so a reader doesn't see the recorded bind-value list and conclude the wire path must be extended-Query. Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 4316715 - Browse repository at this point
Copy the full SHA 4316715View commit details -
fastapi-sqlalchemy-pg-catalog/app: drop redundant future=True on crea…
…te_engine SQLAlchemy 2.x defaults to the future-2.0 behaviour; passing `future=True` is redundant and can trip a deprecation warning in some 2.x point releases. Dropped to keep the sample free of incidental warning noise that would distract from the dispatcher-bug repro. Refs Copilot review on #102. Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 226009f - Browse repository at this point
Copy the full SHA 226009fView commit details -
fastapi-sqlalchemy-pg-catalog/app: dispose engine pool on lifespan sh…
…utdown Add try/finally around the lifespan yield so engine.dispose() runs at shutdown. Releases pooled psycopg2 connections cleanly across repeated start/stop cycles (local repro loops, CI lane reruns), which otherwise leak half-open postgres connections. Refs Copilot review on #102. Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 6e97dd3 - Browse repository at this point
Copy the full SHA 6e97dd3View commit details -
fastapi-sqlalchemy-pg-catalog/app: wrap create_all in the lifespan tr…
…y/finally Copilot noted that the previous try/finally only covered the yield, so a failure in create_all (the *exact* failure mode this repro demonstrates: pre-fix keploy makes create_all raise psycopg2.DatabaseError) wouldn't reach the finally and the engine pool would leak. Moved the startup logging + create_all call inside the try block; finally now runs regardless of where the failure occurs. Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for bd9cfc0 - Browse repository at this point
Copy the full SHA bd9cfc0View commit details -
fastapi-sqlalchemy-pg-catalog/init.sql: clarify when NOT EXISTS actua…
…lly matters Copilot noted /docker-entrypoint-initdb.d scripts only run on first database initialization, so the previous comment's framing ('re-run against an existing volume') was misleading. Reworded to call out the actual scenario: this is a single-shot insert on a clean volume, and NOT EXISTS is defensive coverage for stale-volume reuse. Signed-off-by: Akash Kumar <meakash7902@gmail.com>Configuration menu - View commit details
-
Copy full SHA for 7ae4d92 - Browse repository at this point
Copy the full SHA 7ae4d92View commit details -
fastapi-sqlalchemy-pg-catalog/init.sql: drop NOT EXISTS — script only…
… runs on first init Copilot's repeated note: /docker-entrypoint-initdb.d scripts run only on first database init. On a stale data volume the script doesn't run at all, so the NOT EXISTS guard couldn't help anyway. Simplified to a plain INSERT and updated the comment to tell readers to recreate the volume (docker compose down -v) if they want a deterministic repro. Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 3ab1ea3 - Browse repository at this point
Copy the full SHA 3ab1ea3View commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff main...add-fastapi-sqlalchemy-pg-catalog