Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: keploy/samples-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: keploy/samples-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: add-fastapi-sqlalchemy-pg-catalog
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 10 commits
  • 7 files changed
  • 1 contributor

Commits on May 11, 2026

  1. 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>
    AkashKumar7902 committed May 11, 2026
    Configuration menu
    Copy the full SHA
    61a61e6 View commit details
    Browse the repository at this point in the history
  2. 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>
    AkashKumar7902 committed May 11, 2026
    Configuration menu
    Copy the full SHA
    4becdde View commit details
    Browse the repository at this point in the history

Commits on May 12, 2026

  1. 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>
    AkashKumar7902 committed May 12, 2026
    Configuration menu
    Copy the full SHA
    ec3174e View commit details
    Browse the repository at this point in the history
  2. 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>
    AkashKumar7902 committed May 12, 2026
    Configuration menu
    Copy the full SHA
    3203a0a View commit details
    Browse the repository at this point in the history
  3. 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>
    AkashKumar7902 committed May 12, 2026
    Configuration menu
    Copy the full SHA
    4316715 View commit details
    Browse the repository at this point in the history
  4. 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>
    AkashKumar7902 committed May 12, 2026
    Configuration menu
    Copy the full SHA
    226009f View commit details
    Browse the repository at this point in the history
  5. 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>
    AkashKumar7902 committed May 12, 2026
    Configuration menu
    Copy the full SHA
    6e97dd3 View commit details
    Browse the repository at this point in the history
  6. 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>
    AkashKumar7902 committed May 12, 2026
    Configuration menu
    Copy the full SHA
    bd9cfc0 View commit details
    Browse the repository at this point in the history
  7. 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>
    AkashKumar7902 committed May 12, 2026
    Configuration menu
    Copy the full SHA
    7ae4d92 View commit details
    Browse the repository at this point in the history
  8. 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>
    AkashKumar7902 committed May 12, 2026
    Configuration menu
    Copy the full SHA
    3ab1ea3 View commit details
    Browse the repository at this point in the history
Loading