-
Notifications
You must be signed in to change notification settings - Fork 225
Description
Most appropriate sections of the p5.js website?
Home
What is your operating system?
Windows
Web browser and version
No response
Actual Behavior
Currently, the src/components/GridItem/Sketch.astro component assumes that the item prop passed from the OpenProcessing API will always be valid. However, if the API returns an error (such as the recent 403 Forbidden or 500 Internal Server Error), the item variable becomes undefined.
When the component attempts to execute the following line:
const imgSrc = await getSketchThumbnailSource(item.visualID)
It throws an Uncaught TypeError: Cannot read properties of undefined (reading 'visualID'). In the Astro rendering engine, this results in a critical failure that can prevent the entire page (or the sketch grid section) from rendering.
Expected Behavior
The website should be resilient to external API failures. If a specific sketch's data is missing, the component should exit gracefully (render nothing) instead of crashing the entire application.
Proposed Fix (Guard Clause):
Implement a defensive guard clause at the top of the src/components/GridItem/Sketch.astro frontmatter.
Steps to reproduce
- Run the server locally.
- Bypass API Error: Manually bypass/ignore the
getCurationSketches403/500 error (Build fails with getCurationSketches when OP API inaccessible #1187) to allow the build to proceed. - Observe Error: Even with the API error bypassed, the page fails to render with:
TypeError: Cannot read properties of undefined (reading 'visualID') at src/components/GridItem/Sketch.astro.
Would you like to work on the issue?
Yes