test(search): /api/es IT coverage + docs for non-finite _score regression (#36478) - #36489
Merged
Merged
Conversation
…gotcha (#36478) Follow-up hardening for the #36478 regression (non-finite `_score` → HTTP 500 "JSON does not allow non-finite numbers", fixed on main by #36480). The base fix had unit coverage only; the field-sorted trigger was never exercised end-to-end. - Integration coverage in ESContentResourcePortletTest (already registered in MainSuite2a) for both affected endpoints: * /api/es/search — field-sorted query (NaN score) → HTTP 200, _score: null * /api/es/raw — same query via searchRaw() request body → HTTP 200, _score: null * control: track_scores=true keeps a finite _score (guard must not alter finite scores) - Document the failure class in docs/backend/OPENSEARCH_MIGRATION.md (Known Gotchas): manual JSON serialization of values sourced from an underlying API that can return NaN/Infinity — the strict dotCMS JSONObject throws (500), Jackson emits invalid JSON tokens; coerce non-finite float/double to null (ES-native wire format). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5 tasks
Contributor
|
Claude finished @fabrizzio-dotCMS's task in 3m 22s —— View job PR Review — test(search): /api/es IT coverage + docs for non-finite
|
5 tasks
ihoffmann-dot
approved these changes
Jul 10, 2026
|
Tick the box to add this pull request to the merge queue (same as
|
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.
Proposed Changes
Follow-up to #36478. The base fix (non-finite
_score→ HTTP 500"JSON does not allow non-finite numbers.") landed onmainvia #36480 with unit coverage only. This PR adds the missing end-to-end integration coverage for the actual production trigger, and documents the failure class so it does not recur.No production code change — this is test + docs on top of the merged fix.
ESContentResourcePortletTest(already registered inMainSuite2a), covering both affected endpoints with the reliable NaN trigger (a query that sorts by a field withouttrack_scores):/api/es/search(search()) → field-sorted query → HTTP 200 with each hit's_score=null./api/es/raw(searchRaw(), body read from the request input stream) → same query → HTTP 200 with_score=null./api/es/rawshares thetoLegacyEsJsonadapter, so it is subject to the same regression.track_scores: truekeeps a finite_score(the guard must not alter legitimate scores).docs/backend/OPENSEARCH_MIGRATION.md→ Known Gotchas → new section "Non-finite numbers (NaN/Infinity) in manual JSON serialization".Why this matters
The existing integration tests only exercise relevance-scored
bool/termqueries, so the field-sorted path that producesNaNscores in production was never covered end-to-end. The unit test proves the mapping logic; these ITs prove the full REST → phase-awareSearchAPI→ neutral response → legacy-wire adapter path returns valid JSON.Documented gotcha (prevention)
Any
float/doubleserialized from an underlying search/index/DB/compute API can be non-finite (_scoreisNaNon field-sorted / filter /constant_score/ aggregation-only queries; also suggester scores, aggregation metrics, computed ratios). The two serializers fail differently:JSONObject/JSONArraytestValidity()throws — eagerly input(...)and again at serialization innumberToStringObjectMapperNaN/Infinitytokens (not valid JSON)Rule: coerce non-finite
float/doubletonull(ES-native wire format) before it reaches the serializer.Checklist
ESContentResourcePortletTest(registered inMainSuite2a); moduletest-compilepasses.Notes
main(fix(search): guard non-finite _score in /api/es/search response (#36478) #36480); this PR does not re-touchESContentResourcePortlet.distancepath was verified as a false positive — model embeddings are never zero-magnitude, so pgvector cosine distance stays finite).This PR relates to: #36478
🤖 Generated with Claude Code
This PR fixes: #36478