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
- Check the graph name against the list returned by the graphs listing endpoint / graphLoader.listGraphs().
- Look at the server log: the handler logs 'Failed to get graph representation' with the full stack trace before returning 404.
- Fix graph registration/loading errors (missing bean, compile failure) so loadGraph succeeds.
- 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
- Cross-check graph names against the graphs listing endpoint.
- Register all graphs with Studio's GraphLoader at startup.
- Read server logs: the 404 wraps any load or Mermaid rendering exception.
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
- Graph not found:
- Thread found but belongs to a different graph/user.
- Thread not found: graphName=
- APP_COMPONENT_QUERYCONFIG_ERROR
- APP_COMPONENT_REFER_ERROR
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)