Skip to content

Refuse a non-finite cluster eps inside the resolver too - #421

Merged
lstein merged 2 commits into
masterfrom
lstein/fix/non-finite-cluster-eps-guard
Oct 6, 2026
Merged

lstein merged 2 commits into
masterfrom
lstein/fix/non-finite-cluster-eps-guard

Conversation

@lstein

@lstein lstein commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Fixes #379.

Most of #379 was already fixed by #375: /umap_data, /cluster_labels, /set_umap_eps, /add_album and /update_album now return a 422 for a non-finite or below-floor eps, and a config that already holds .inf/.nan is repaired when it loads. Two things the issue asked for were still missing.

Resolver guard

photomap/backend/cluster_eps.py still trusted its input. _shrink_eps_to_pair_budget(coords, inf) loops forever once an album is over the neighbour-pair budget, because inf * 0.7 is still inf. nan fails both of the loop's comparisons and goes on to DBSCAN, which raises. A small _require_finite() check now raises ValueError in two places:

  • at the start of the shrink, so the loop can never run forever;
  • in resolve_album_cluster_eps, because an album with no coordinates returns before it reaches the shrink.

The routers still reject these values before they reach the resolver; this check is for any other caller.

Tests

  • /umap_data and /cluster_labels are now also tested with nan, NaN, inf, Infinity, -inf and 1e400 as cluster_eps (before, only 0, -1 and 0.005).
  • New unit tests cover the resolver guard, including the empty-album and None-coords cases. They use small maps, so if the guard is removed they fail straight away rather than hanging CI. With the guard removed, all 8 fail.

Full backend suite: 1301 passed; ruff check is clean.

🤖 Generated with Claude Code

lstein and others added 2 commits October 4, 2026 17:07
The routers already 422 a non-finite cluster_eps (#375), but the
resolver itself still trusted its input: _shrink_eps_to_pair_budget
loops forever on inf once an album is over the pair budget, and nan
slips past both of its comparisons into DBSCAN. Raise ValueError there,
and in resolve_album_cluster_eps for the empty-album path that returns
before the shrink. Also cover nan/inf/1e400 query values on /umap_data
and /cluster_labels, which were not tested.

Fixes #379

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@lstein
lstein enabled auto-merge (squash) October 6, 2026 17:46
@lstein
lstein merged commit 1a87539 into master Oct 6, 2026
10 checks passed
@lstein
lstein deleted the lstein/fix/non-finite-cluster-eps-guard branch October 6, 2026 18:02
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.

Non-finite cluster_eps either 500s or wedges a worker thread forever

1 participant