fix(explore): null processing-summary param + Svelte 5 reactivity #655

Merged
chris merged 3 commits from fix/explore-loading into main 2026-07-20 14:38:45 +02:00
Owner

Bug 1: GET /api/processing-summary?refresh=123 → HTTP 500

Root cause: ProcessingSummaryService.activities() line 80 — resetCutoff() returns null when resetEventTypes is empty (thumbnails, metadata, semantic_search). Spring JdbcClient binds null to a Timestamp param without SQL type hint → PostgreSQL throws "could not determine data type of parameter $N" → 500.

Fix: Replace null sentinel with Timestamp.from(Instant.EPOCH). Instant.EPOCH (1970-01-01) includes ALL timestamps — same semantics as "no cutoff". Removed the now-redundant OR :finishedCutoff IS NULL clauses from the SQL.

File: apps/api/src/main/java/dev/memories/api/processing/ProcessingSummaryService.java:80-87

Bug 2: /explore page — People and Plants stuck on "Loading..."

Root cause (confirmed by code analysis): apps/web/src/routes/explore/+page.svelte:170-186 — loadDomainInstances() mutates section.loading and section.instances on objects passed by reference from a void fire-and-forget async call. In Svelte 5 legacy mode (no $state runes), mutations to nested properties of let variables are NOT automatically tracked — only top-level reassignment triggers re-render. The template never updates because Svelte's compiler doesn't know these mutations happened.

Fix: Reassign domainSections = domainSections in the finally block after mutations, forcing Svelte invalidation.

File: apps/web/src/routes/explore/+page.svelte:183-185

Runtime check notes

The backend endpoints (GET /api/discovery/domains/people/class-instances and plants equivalent) return 200 with valid data. The bug is purely a frontend reactivity issue — the data arrives but the UI never re-renders to show it.

Tests

  • Bug 1: Added noAuditEventResetRowsDoesNotCauseNullParamError to ProcessingSummaryServiceTest.java. H2 passes (doesn't reproduce original PG bug) but verifies no NPE on the null→EPOCH conversion path. Comment documents the H2 vs PG difference.
  • Bug 2: No automated test — Svelte 5 reactivity requires browser runtime. Verified via svelte-check (0 errors). Manual browser testing recommended.
## Bug 1: GET /api/processing-summary?refresh=123 → HTTP 500 **Root cause:** `ProcessingSummaryService.activities()` line 80 — `resetCutoff()` returns `null` when `resetEventTypes` is empty (thumbnails, metadata, semantic_search). Spring JdbcClient binds null to a Timestamp param without SQL type hint → PostgreSQL throws "could not determine data type of parameter $N" → 500. **Fix:** Replace null sentinel with `Timestamp.from(Instant.EPOCH)`. Instant.EPOCH (1970-01-01) includes ALL timestamps — same semantics as "no cutoff". Removed the now-redundant `OR :finishedCutoff IS NULL` clauses from the SQL. **File:** `apps/api/src/main/java/dev/memories/api/processing/ProcessingSummaryService.java:80-87` ## Bug 2: /explore page — People and Plants stuck on "Loading..." **Root cause (confirmed by code analysis):** `apps/web/src/routes/explore/+page.svelte:170-186` — `loadDomainInstances()` mutates `section.loading` and `section.instances` on objects passed by reference from a `void` fire-and-forget async call. In Svelte 5 legacy mode (no `$state` runes), mutations to nested properties of `let` variables are NOT automatically tracked — only top-level reassignment triggers re-render. The template never updates because Svelte's compiler doesn't know these mutations happened. **Fix:** Reassign `domainSections = domainSections` in the `finally` block after mutations, forcing Svelte invalidation. **File:** `apps/web/src/routes/explore/+page.svelte:183-185` ## Runtime check notes The backend endpoints (`GET /api/discovery/domains/people/class-instances` and plants equivalent) return 200 with valid data. The bug is purely a frontend reactivity issue — the data arrives but the UI never re-renders to show it. ## Tests - **Bug 1:** Added `noAuditEventResetRowsDoesNotCauseNullParamError` to `ProcessingSummaryServiceTest.java`. H2 passes (doesn't reproduce original PG bug) but verifies no NPE on the null→EPOCH conversion path. Comment documents the H2 vs PG difference. - **Bug 2:** No automated test — Svelte 5 reactivity requires browser runtime. Verified via `svelte-check` (0 errors). Manual browser testing recommended.
When resetEventTypes is empty, resetCutoff() returned null. Spring JdbcClient
bound null to a Timestamp param without SQL type hint, causing PostgreSQL to
throw 'could not determine data type of parameter ' → HTTP 500.

Fix: convert null cutoff to Timestamp.from(Instant.EPOCH) which includes ALL
timestamps (same semantics as 'no cutoff'). Remove the now-redundant
'OR :finishedCutoff IS NULL' clauses from the SQL.

H2 masked this bug (accepts null params silently). Added regression test that
exercises the empty-resetEventTypes path; passes on both H2 and PG.
fix(explore): force Svelte 5 reactivity after async domain instance loading
Some checks failed
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Failing after 3m44s
9cd7877b84
In loadDomainInstances(), section.loading and section.instances are mutated
on objects passed by reference from a void fire-and-forget call. Svelte 5
legacy mode (no $state runes) does not deep-track nested property mutations
on let variables — only top-level reassignment triggers re-render.

Fix: reassign domainSections = domainSections in the finally block after
mutations, forcing Svelte to invalidate and re-render the template.

This was the root cause of People and Plants sections stuck on 'Loading...'
chore: bump version to v1.21.13
All checks were successful
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 1m46s
f7ca98696f
chris merged commit d9d8cbfdcb into main 2026-07-20 14:38:45 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!655
No description provided.