alibaba/spring-ai-alibaba · error · ResponseStatusException

Graph not found:

Error message

Graph not found: 

What it means

GraphController.getGraphRepresentation converts any exception during graph loading or Mermaid rendering into a 404 NOT_FOUND ResponseStatusException with message 'Graph not found: <graphName>'. Because it catches all Exceptions, even rendering errors are surfaced as 'not found'.

Solutions

  1. Check the graph name against the list returned by the graphs listing endpoint / graphLoader.listGraphs().
  2. Look at the server log: the handler logs 'Failed to get graph representation' with the full stack trace before returning 404.
  3. Fix graph registration/loading errors (missing bean, compile failure) so loadGraph succeeds.
  4. If it's a rendering failure (not a missing graph), fix the graph structure rather than the name.

Example fix

// before
GET /graphs/agent grap/representation
// after
GET /graphs/agent-graph/representation  // name must match a loaded graph exactly
Defensive patterns

Strategy: validation

Validate before calling

// client-side, before requesting representation
const graphs = await (await fetch('/graphs')).json();
if (!graphs.includes(graphName)) throw new Error(`Graph '${graphName}' is not loaded`);

Try / catch

try {
  const res = await fetch(`/graphs/${graphName}/representation`);
  if (res.status === 404) { /* check server logs: load vs render failure */ }
} catch (e) { /* handle */ }

Prevention

When it happens

Trigger: GET /graphs/{graphName}/representation where graphLoader.loadGraph(graphName) throws (unknown graph name, graph failed to compile) or graph.getGraph(MERMAID,...) throws.

Common situations: Typo in graph name; graph class not registered/loaded in the Studio application; graph bean fails to build at load time; caller assumes a graph exists that was never loaded.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/f8a4fb29ccd4f95c. Report an issue: GitHub.

Appendix: source

Thrown at spring-ai-alibaba-studio/src/main/java/com/alibaba/cloud/ai/agent/studio/controller/GraphController.java:86

	 *
	 * @param graphName The name of the graph.
	 * @return GraphResponse containing the Mermaid diagram source.
	 */
	@GetMapping("/graphs/{graphName}/representation")
	public GraphResponse getGraphRepresentation(@PathVariable String graphName) {
		if (graphName == null || graphName.isBlank()) {
			throw new ResponseStatusException(org.springframework.http.HttpStatus.BAD_REQUEST,
					"graphName cannot be null or empty");
		}
		try {
			CompiledGraph graph = graphLoader.loadGraph(graphName);
			String title = graph.stateGraph != null ? graph.stateGraph.getName() : graphName;
			GraphRepresentation repr = graph.getGraph(GraphRepresentation.Type.MERMAID, title);
			return new GraphResponse(repr.content(), true);
		}
		catch (Exception e) {
			log.warn("Failed to get graph representation for: {}", graphName, e);
			throw new ResponseStatusException(org.springframework.http.HttpStatus.NOT_FOUND,
					"Graph not found: " + graphName, e);
		}
	}
}

View on GitHub (pinned to f82da0b50f)