Skip to content

search: don't set type-mismatched facet after a prior load error - #417

Open
Usamak06 wants to merge 1 commit into
golang:masterfrom
Usamak06:search-facet-mismatch-skip
Open

Usamak06 wants to merge 1 commit into
golang:masterfrom
Usamak06:search-facet-mismatch-skip

Conversation

@Usamak06

Copy link
Copy Markdown

structFLS.Load skips a type-mismatched facet only for the first error it records: the continue for the type-mismatch case sits inside the if err == nil guard, so once an earlier facet or field has set err, a later facet whose value type doesn't match the destination field falls through to reflect.Value.Set and panics (for example assigning an Atom to a float64 facet field). Facet data comes from the indexed document returned by the search backend, so loading a result whose facets don't line up with the destination struct crashes the request handler. Moved the continue out of the error guard so a mismatched facet is always skipped, matching the field loop and the other two facet checks in the same function, with the same change in v2 and a regression test.

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