Repository navigation
Refuse a non-finite cluster eps inside the resolver too - #421
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #379.
Most of #379 was already fixed by #375:
/umap_data,/cluster_labels,/set_umap_eps,/add_albumand/update_albumnow return a 422 for a non-finite or below-floor eps, and a config that already holds.inf/.nanis repaired when it loads. Two things the issue asked for were still missing.Resolver guard
photomap/backend/cluster_eps.pystill trusted its input._shrink_eps_to_pair_budget(coords, inf)loops forever once an album is over the neighbour-pair budget, becauseinf * 0.7is stillinf.nanfails both of the loop's comparisons and goes on to DBSCAN, which raises. A small_require_finite()check now raisesValueErrorin two places: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_dataand/cluster_labelsare now also tested withnan,NaN,inf,Infinity,-infand1e400ascluster_eps(before, only 0, -1 and 0.005).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 checkis clean.🤖 Generated with Claude Code