Skip to content

[BUG] Critical rendering crash in Sketch.astro when OpenProcessing API fails #1191

@priyaa-j

Description

@priyaa-j

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

  1. Run the server locally.
  2. Bypass API Error: Manually bypass/ignore the getCurationSketches 403/500 error (Build fails with getCurationSketches when OP API inaccessible #1187) to allow the build to proceed.
  3. 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

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions