-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Description
Description
While a product in the shopping config must have a productImages key according to the JSON schema (see #36460), it is technically not required to have any images. So an empty productImages array does not fail validation.
However, it causes an uncaught TypeError in this code here that expects at least 1 image to exist:
amphtml/extensions/amp-story-shopping/0.1/amp-story-shopping-attachment.js
Lines 516 to 519 in 0d845fd
| backgroundImage: `url("${relativeToSourceUrl( | |
| data['productImages'][0].url, | |
| this.element | |
| )}")`, |
Reproduction Steps
- Add
amp-story-shoppingconfiguration with at least two products, where at least one product does not have any images, i.e.productImages = [] - Click on the shopping attachment
- See error in console and that the attachment does not open
In my testing it somehow worked on the first page, but the error was always thrown
Relevant Logs
Uncaught TypeError: Cannot read properties of undefined (reading 'url')
at amp-story-shopping-attachment.js:517:46
at Array.map (<anonymous>)
at W.I8 (amp-story-shopping-attachment.js:507:32)
at W.pW (amp-story-shopping-attachment.js:277:16)
at W.P8 (amp-story-shopping-attachment.js:220:27)
at W.w8 (amp-story-shopping-attachment.js:155:12)
at amp-story-shopping-attachment.js:126:24
at _i.fire (observable.js:63:7)
at amp-story-store-service.js:571:30
at Array.forEach (<anonymous>)Browser(s) Affected
No response
OS(s) Affected
No response
Device(s) Affected
No response
AMP Version Affected
2204221712000
Reactions are currently unavailable