-
Notifications
You must be signed in to change notification settings - Fork 30
fix(shopify): update color filter handling in toFilter function #1650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -322,6 +322,8 @@ const isSelectedFilter = (filterValue: FilterValue, url: URL) => { | |
|
|
||
| export const toFilter = (filter: FilterShopify, url: URL): Filter => { | ||
| if (!filter.type.includes("RANGE")) { | ||
| const isColorFilter = filter.id === "filter.v.t.shopify.color-pattern"; | ||
|
|
||
| return { | ||
| "@type": "FilterToggle", | ||
| label: filter.label, | ||
|
|
@@ -330,7 +332,9 @@ export const toFilter = (filter: FilterShopify, url: URL): Filter => { | |
| return { | ||
| quantity: value.count, | ||
| label: value.label, | ||
| value: value.label, | ||
| value: !isColorFilter | ||
| ? value.label | ||
| : JSON.parse(value.input).taxonomyMetafield.value, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Unsafe Notice that the existing Prompt for AI agents |
||
| selected: isSelectedFilter(value, url), | ||
| url: filtersURL(filter, value, url), | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Avoid unguarded parsing of color-filter input.
JSON.parse(value.input).taxonomyMetafield.valuethrows when an option has malformed JSON or a missingtaxonomyMetafield, causingtoFilter—and therefore theProductListingPagefilter mapping—to fail. ReusegetFilterValue(value)or add equivalent guarded parsing with a label fallback.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents