alibaba/spring-ai-alibaba · error · IllegalArgumentException
Invalid write mode: {item.writeMode()}
Error message
Invalid write mode: {item.writeMode()} What it means
AssignerNode.apply throws this IllegalArgumentException when a write item's writeMode enum value hits the default branch of the switch, i.e. a write mode the node does not implement (typically a newly added or unknown enum constant). It indicates the assigner does not support that mode.
Source
Thrown at spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/node/AssignerNode.java:124
case CLEAR -> {
if (targetValue instanceof List) {
yield new ArrayList<>();
}
else if (targetValue instanceof Map) {
yield new HashMap<>();
}
else if (targetValue instanceof String) {
yield "";
}
else if (targetValue instanceof Number) {
yield 0;
}
else {
yield null;
}
}
case INPUT_CONSTANT -> item.inputValue();
default -> throw new IllegalArgumentException("Invalid write mode: " + item.writeMode());
};
updates.put(item.targetKey, result);
}
return updates;
}
// Builder pattern
public static Builder builder() {
return new Builder();
}
public static class Builder {
private List<AssignItem> items = new ArrayList<>();
public Builder setItems(List<AssignItem> items) {
this.items = new ArrayList<>(items);
return this;View on GitHub (pinned to f82da0b50f)
Solutions
- Use only write modes supported by your library version (check the WriteMode enum and apply's switch)
- Align library versions so the runtime knows all write modes in your workflow definitions
- Add the missing case to the switch if you maintain a fork/custom mode
Example fix
// before
Item.builder().targetKey("k").writeMode(SomeCustomMode.MERGE) // unsupported
// after
Item.builder().targetKey("k").writeMode(WriteMode.OVERWRITE) Defensive patterns
Strategy: validation
Validate before calling
Set<WriteMode> supported = Set.of(WriteMode.OVERWRITE, WriteMode.APPEND, WriteMode.CLEAR, WriteMode.INPUT_CONSTANT);
if (!supported.contains(item.writeMode())) throw new ConfigException("unsupported write mode: " + item.writeMode()); Try / catch
try {
state = assignerNode.apply(state);
} catch (IllegalArgumentException e) {
throw new WorkflowConfigException("Check WriteMode against library version: " + e.getMessage(), e);
} Prevention
- Pin the starter-builtin-nodes version and only use WriteMode constants from that version
- Check the WriteMode enum after upgrades for new/renamed modes
- Validate serialized workflow definitions against the runtime's supported modes
When it happens
Trigger: Constructing an AssignerNode item with a WriteMode constant not covered by apply's switch (e.g. a mode added in a newer/older library version or INPUT_CONSTANT-adjacent custom modes), so the default case throws.
Common situations: Version mismatch between the workflow definition (serialized write modes) and the library runtime; typos or custom enum extensions; upgrading spring-ai-alibaba-starter-builtin-nodes adds modes your rules use but the pinned runtime lacks.
Related errors
- TOOL_PARAMS_INVALID
- INVALID_PARAMS
- Unknown vector store type:
- Unknown agent status code:
- Unknown agent type code:
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/895fbbd6fb9f129f.
Report an issue: GitHub.