Skip to content

fix: provider/model filters were silently ignored + startup blocked HTTP for the full reindex#70

Merged
0bserver07 merged 1 commit into
mainfrom
fix/query-bindings-and-non-blocking-ingest
May 5, 2026
Merged

fix: provider/model filters were silently ignored + startup blocked HTTP for the full reindex#70
0bserver07 merged 1 commit into
mainfrom
fix/query-bindings-and-non-blocking-ingest

Conversation

@0bserver07
Copy link
Copy Markdown
Owner

Two unrelated bugs surfaced today on real multi-provider data.

Bug 1 — filter query params dropped server-side

PR #66 added ?provider= / ?model= to 5 routes but bound them as bare list[str] | None = None. FastAPI silently keeps these None regardless of URL — every FilterBar toggle in the UI was being thrown away by the backend.

Verified live before fix:

/api/projects?provider=cursor  → 187 projects (all 7 providers)

After fix:

/api/projects?provider=cursor                    →   7 projects
/api/projects?provider=cursor&provider=cline     →   8 projects

Used Annotated[list[str] | None, Query()] = None so direct in-process calls (test pattern) keep None defaults while HTTP-bound calls go through FastAPI binding. Touched: projects, sessions, cost, data (dashboard-data + messages), optimize.

Bug 2 — startup blocked HTTP for the full reindex

_lifespan ran run_ingest() synchronously before yield. Today's startup: 89s of dead time before HTTP started binding, even though the CLI wrapper had already printed "live at http://127.0.0.1:8095". Cold 188-project store would block for ~30 min.

Now: schema apply stays synchronous (cheap, needed by every route), run_ingest() runs in a daemon thread. HTTP starts serving in <1s. "Ingest complete" log still fires when the thread finishes.

Test plan

  • pytest tests/ -q → 1341 passed, 2 skipped
  • Live smoke: ?provider=cursor actually returns 7 projects, not 187
  • No version bump (still v0.6.1)

🤖 Generated with Claude Code

Two issues blocked v0.6.1 multi-provider from working in real use:

1. Filter query params silently ignored on 5 routes.

   FastAPI requires ``Query()`` (or ``Annotated[..., Query()]``) to bind
   repeated list-typed query parameters. Without it the param stays
   ``None`` regardless of what the URL contains. The routes added in
   PR #66 used the bare ``list[str] | None = None`` shape, so every
   ``?provider=...`` / ``?model=...`` filter from FilterBar was being
   dropped on the server side. Verified live before fix:

       /api/projects?provider=cursor → 187 projects (all 7 providers)
       /api/projects?provider=claude → 187 projects (all 7 providers)

   After fix:

       /api/projects                            → 187 projects
       /api/projects?provider=cursor            →   7 projects
       /api/projects?provider=cursor+cline      →   8 projects

   Used ``Annotated[list[str] | None, Query()] = None`` so direct
   in-process calls (existing test pattern) keep getting ``None`` as
   the default while HTTP-bound calls go through FastAPI's normal
   parameter binding. 9 bindings touched across projects, sessions,
   cost, data (dashboard-data + messages), optimize.

2. Startup blocked HTTP for the entire reindex (~90s today, 30+min on
   cold 188-project store).

   The ``_lifespan`` handler ran ``run_ingest()`` synchronously before
   ``yield``, so the HTTP server didn't actually start serving until
   ingest finished — even though the CLI wrapper had already printed
   the misleading "live at..." line. Schema apply still runs sync
   (cheap, needed by every route), but ``run_ingest`` now runs in a
   daemon background thread so HTTP starts serving in <1s. The
   "Ingest complete" log line still fires when the thread finishes;
   any error in the thread degrades to a single ``logger.error`` call,
   matching the previous behaviour.

1341 backend tests pass. No version bump.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@0bserver07 0bserver07 merged commit e561b70 into main May 5, 2026
9 checks passed
@0bserver07 0bserver07 deleted the fix/query-bindings-and-non-blocking-ingest branch May 5, 2026 03:37
0bserver07 added a commit that referenced this pull request May 20, 2026
Two issues blocked v0.6.1 multi-provider from working in real use:

1. Filter query params silently ignored on 5 routes.

   FastAPI requires ``Query()`` (or ``Annotated[..., Query()]``) to bind
   repeated list-typed query parameters. Without it the param stays
   ``None`` regardless of what the URL contains. The routes added in
   PR #66 used the bare ``list[str] | None = None`` shape, so every
   ``?provider=...`` / ``?model=...`` filter from FilterBar was being
   dropped on the server side. Verified live before fix:

       /api/projects?provider=cursor → 187 projects (all 7 providers)
       /api/projects?provider=claude → 187 projects (all 7 providers)

   After fix:

       /api/projects                            → 187 projects
       /api/projects?provider=cursor            →   7 projects
       /api/projects?provider=cursor+cline      →   8 projects

   Used ``Annotated[list[str] | None, Query()] = None`` so direct
   in-process calls (existing test pattern) keep getting ``None`` as
   the default while HTTP-bound calls go through FastAPI's normal
   parameter binding. 9 bindings touched across projects, sessions,
   cost, data (dashboard-data + messages), optimize.

2. Startup blocked HTTP for the entire reindex (~90s today, 30+min on
   cold 188-project store).

   The ``_lifespan`` handler ran ``run_ingest()`` synchronously before
   ``yield``, so the HTTP server didn't actually start serving until
   ingest finished — even though the CLI wrapper had already printed
   the misleading "live at..." line. Schema apply still runs sync
   (cheap, needed by every route), but ``run_ingest`` now runs in a
   daemon background thread so HTTP starts serving in <1s. The
   "Ingest complete" log line still fires when the thread finishes;
   any error in the thread degrades to a single ``logger.error`` call,
   matching the previous behaviour.

1341 backend tests pass. No version bump.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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