Symptom
The whole search results page crashes with the Volto error page:
TypeError: Cannot read properties of undefined (reading 'match')
at ImageResultItem
Reproduced on the demo site (main, 3.0.0a2 code) with /search?SearchableText=Labor — the default All tab includes Image results, and one of them has no mime_type in the Solr response.
Root cause
frontend/packages/volto-solr/src/components/theme/SolrSearch/resultItems/helpers/ImageType.jsx:
export const getImageType = (mimeType) => {
const matchImage = mimeType.match(/image\/(.*)/); // ← no guard
ImageResultItem calls it twice with a possibly-undefined value whenever the item has a date:
if2={getImageType(item?.extras?.mime_type)}
...
<ImageType mimeType={item?.extras?.mime_type} />
The optional chaining on the caller's side passes undefined straight into .match().
Impact
One badly indexed Image takes down the entire results page (not just its own tile). More visible since images are included in default suggestions/results (#126) — a user can navigate into the crash from the search dialog.
Suggested fix
Guard in getImageType: if (!mimeType) return null; — consistent with its existing null return path for non-image mime types; the footer then simply omits the type label. Optionally also investigate why an Image can be indexed without mime_type (demo-site content import), but the frontend must tolerate it regardless.
Found while taking screenshots of the demo site; the crash predates #126 (present for any Image result on the results page).
Symptom
The whole search results page crashes with the Volto error page:
Reproduced on the demo site (main, 3.0.0a2 code) with
/search?SearchableText=Labor— the default All tab includes Image results, and one of them has nomime_typein the Solr response.Root cause
frontend/packages/volto-solr/src/components/theme/SolrSearch/resultItems/helpers/ImageType.jsx:ImageResultItemcalls it twice with a possibly-undefined value whenever the item has a date:The optional chaining on the caller's side passes
undefinedstraight into.match().Impact
One badly indexed Image takes down the entire results page (not just its own tile). More visible since images are included in default suggestions/results (#126) — a user can navigate into the crash from the search dialog.
Suggested fix
Guard in
getImageType:if (!mimeType) return null;— consistent with its existingnullreturn path for non-image mime types; the footer then simply omits the type label. Optionally also investigate why an Image can be indexed withoutmime_type(demo-site content import), but the frontend must tolerate it regardless.Found while taking screenshots of the demo site; the crash predates #126 (present for any Image result on the results page).