Documentation Index
Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
Use this file to discover all available pages before exploring further.
A LangGraph StateGraph
received a non-object return type from a node. Here’s an example:
import { z } from "zod/v4";
import { StateGraph, StateSchema, GraphNode } from "@langchain/langgraph";
const State = new StateSchema({
someKey: z.string(),
});
const badNode: GraphNode<typeof State> = (state) => {
// Should return an object with a value for "someKey", not an array
return ["whoops"];
};
const builder = new StateGraph(State).addNode("badNode", badNode);
// ...
const graph = builder.compile();
Invoking the above graph will result in an error like this:
await graph.invoke({ someKey: "someval" });
InvalidUpdateError: Expected object, got ['whoops']
For troubleshooting, visit: https://langchain-ai.github.io/langgraphjs/troubleshooting/errors/INVALID_GRAPH_NODE_RETURN_VALUE
Nodes in your graph must return an object containing one or more keys defined in your state.
Troubleshooting
The following may help resolve this error:
- If you have complex logic in your node, make sure all code paths return an appropriate object for your defined state.