Skip to content

Validate API graph shape and add an error boundary around the diagram render #45

Open

Description

@DataDave-Dev

🇪🇸 Español

La respuesta de la API se castea directo a Graph (setGraph(data as Graph)) sin validación, y luego layout() hace muchas aserciones non-null y recursión sin límite (sizeOf/ancestorIn). Datos malformados o con ciclos en parent lanzan o entran en bucle infinito durante el render, tumbando todo el árbol de cliente (el try/catch del fetch no cubre el render).

Archivos: src/components/ui/CodeWorkspace.tsx:451-452, src/components/ui/Diagram.tsx:69-234

Solución sugerida: Validar la respuesta con un schema en el borde, envolver <Diagram> en un error boundary y proteger la recursión con un set de visitados.


🇬🇧 English

The API response is cast straight to Graph (setGraph(data as Graph)) with no validation, then layout() runs many non-null assertions and unbounded recursion (sizeOf/ancestorIn). Malformed or cyclic-parent data throws or infinite-loops during render, crashing the whole client tree (the fetch try/catch does not cover render).

Files: src/components/ui/CodeWorkspace.tsx:451-452, src/components/ui/Diagram.tsx:69-234

Suggested fix: Validate the response with a schema at the boundary, wrap <Diagram> in an error boundary, and guard the recursion with a visited set.

Activity

  1. added
    bug
    help wanted
    on Jun 16, 2026
  2. self-assigned this
    on Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions