aaif-goose/goose · warning

Sankey data must include at least one node and one link.

Error message

Sankey data must include at least one node and one link.

What it means

Client-side guard inside the D3 sankey HTML template rendered by the autovisualiser MCP tool: renderData() requires data.nodes and data.links to be non-empty arrays before calling drawSankey, because d3-sankey throws cryptic errors on empty graphs. The thrown error is immediately caught and displayed in the SVG as 'Unable to render diagram: ...', so it degrades to an inline message rather than crashing the webview.

Source

Thrown at crates/goose-mcp/src/autovisualisation/templates/sankey_template.html:225

View on GitHub (pinned to 3810898a74)

Solutions

  1. Ensure the Sankey payload has at least one node AND one link (source+target pair) before rendering
  2. If the data genuinely has no flows, pick a different chart type (bar/table) instead of a sankey
  3. Filter/aggregate upstream so trivial flows still produce one link rather than an empty set
  4. If you are the tool author: validate nodes/links length in the Rust handler before sending data to the template

Example fix

// before
renderData({ nodes: [{ name: 'A' }], links: [] }); // throws inside template
// after
renderData({
  nodes: [{ name: 'A' }, { name: 'B' }],
  links: [{ source: 0, target: 1, value: 10 }],
});
Defensive patterns

Strategy: validation

Validate before calling

// (template-side, before McpAppBridge onData -> renderData)
function isRenderableSankey(data) {
  return Boolean(
    data && Array.isArray(data.nodes) && data.nodes.length > 0 &&
    Array.isArray(data.links) && data.links.length > 0
  );
}

Type guard

const isNonEmptySankey = (d: unknown): d is { nodes: unknown[]; links: unknown[] } =>
  typeof d === 'object' && d !== null &&
  Array.isArray((d as any).nodes) && (d as any).nodes.length > 0 &&
  Array.isArray((d as any).links) && (d as any).links.length > 0;

Try / catch

// Already handled internally: renderData catches and draws
// 'Unable to render diagram: <message>'. Callers should validate data shape
// upstream so users never see the fallback text.

Prevention

When it happens

Trigger: The model/autovisualiser tool sends a Sankey spec with nodes: [] or links: [] (e.g. the underlying data summarized to nothing, or all edges were filtered out); a dataset with only isolated nodes and no links; malformed payload where nodes/links keys exist but are empty arrays.

Common situations: LLM generating a chart from a table whose flows all collapsed to zero; user asking for a flow diagram of data with a single category (no links possible); upstream aggregation bugs producing empty edge lists.

Related errors


AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16). Data as JSON: /api/errors/439f583939401bee. Report an issue: GitHub.