alibaba/spring-ai-alibaba · warning · ResponseStatusException

graphName cannot be null or empty

Error message

graphName cannot be null or empty

What it means

GraphThreadController.validateGraphExists first rejects a null/blank graphName with a 400 BAD_REQUEST ResponseStatusException before checking graph existence. It is called by all thread endpoints (getThread, listThreads, createThreadWithId, createThread, deleteThread).

Solutions

  1. Supply a valid non-blank graph name in the request path.
  2. Validate graphName client-side before issuing the request.
  3. Verify router/path parameter bindings aren't dropping the value.

Example fix

// before
const url = `/graphs/${graphName}/users/${userId}/threads`;
// after
if (!graphName || !graphName.trim()) return Promise.reject('graphName required');
const url = `/graphs/${encodeURIComponent(graphName)}/users/${userId}/threads`;
Defensive patterns

Strategy: validation

Validate before calling

// client-side guard before any thread API call
if (!graphName || !graphName.trim()) {
  throw new Error('graphName is required for thread APIs');
}

Type guard

function isValidGraphParam(name) {
  return typeof name === 'string' && name.trim().length > 0;
}

Try / catch

try {
  await api.get(`/graphs/${graphName}/users/${userId}/threads`);
} catch (e) {
  if (e.response?.status === 400) { /* blank graphName - fix request */ }
}

Prevention

When it happens

Trigger: Any thread API call under /graphs/{graphName}/users/... with an empty or whitespace-only graphName path segment.

Common situations: Client building URLs from an unset variable; URL-encoded blank segments; misconfigured frontend router passing empty params.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

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

	private static final String EVAL_SESSION_ID_PREFIX = "SAA_EVAL_";

	private final GraphLoader graphLoader;

	private final ThreadService threadService;

	@Autowired
	public GraphThreadController(GraphLoader graphLoader, ThreadService threadService) {
		this.graphLoader = graphLoader;
		this.threadService = threadService;
	}

	private String toAppName(String graphName) {
		return GRAPH_APP_PREFIX + graphName;
	}

	private void validateGraphExists(String graphName) {
		if (graphName == null || graphName.isBlank()) {
			throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "graphName cannot be null or empty");
		}
		if (!graphLoader.listGraphs().contains(graphName)) {
			throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Graph not found: " + graphName);
		}
	}

	private Thread findThreadOrThrow(String graphName, String userId, String threadId) {
		String appName = toAppName(graphName);
		Optional<Thread> optionalThread =
				threadService.getThread(appName, userId, threadId, Optional.empty()).block();

		if (optionalThread == null || !optionalThread.isPresent()) {
			throw new ResponseStatusException(HttpStatus.NOT_FOUND,
					String.format("Thread not found: graphName=%s, userId=%s, threadId=%s",
							graphName, userId, threadId));
		}

		Thread thread = optionalThread.get();

View on GitHub (pinned to f82da0b50f)