alibaba/spring-ai-alibaba · error · IllegalArgumentException
SkillRegistry cannot be null
Error message
SkillRegistry cannot be null
What it means
ReadSkillTool's constructor rejects a null SkillRegistry. This tool delegates all skill-content reads to the registry, so without it the tool could never resolve a skill; the library validates at construction time and fails immediately.
Source
Thrown at spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/hook/skills/ReadSkillTool.java:60
public static final String DESCRIPTION = """
Reads the full content of a skill from the SkillRegistry.
You can use this tool to read the complete content of any skill by providing its name or path.
Usage:
- Provide either skill_name or skill_path
- If both are provided, they must refer to the same skill
- The tool returns the full content of the skill file (e.g., SKILL.md) without frontmatter
- If the skill is not found, an error will be returned
Example:
- read_skill("pdf-extractor")
""";
private static final Logger logger = LoggerFactory.getLogger(ReadSkillTool.class);
private final SkillRegistry skillRegistry;
public ReadSkillTool(SkillRegistry skillRegistry) {
if (skillRegistry == null) {
throw new IllegalArgumentException("SkillRegistry cannot be null");
}
this.skillRegistry = skillRegistry;
}
/**
* Create a ToolCallback for the read skill tool.
*/
public static ToolCallback createReadSkillToolCallback(SkillRegistry skillRegistry, String description) {
return FunctionToolCallback.builder(READ_SKILL, new ReadSkillTool(skillRegistry))
.description(description != null ? description : DESCRIPTION)
.inputType(ReadSkillRequest.class)
.build();
}
@Override
public String apply(ReadSkillRequest request, ToolContext toolContext) {
try {
return readSkillContent(request);View on GitHub (pinned to f82da0b50f)
Solutions
- Instantiate the registry first: SkillRegistry registry = FileSystemSkillRegistry.builder().build(); then pass it to ReadSkillTool.
- Only register the read-skill tool callback when a valid SkillRegistry exists.
- Audit any wrapper that forwards a possibly-null registry into the ReadSkillTool factory.
Example fix
// before ReadSkillTool tool = new ReadSkillTool(null); // after SkillRegistry registry = FileSystemSkillRegistry.builder().build(); ReadSkillTool tool = new ReadSkillTool(registry);
Defensive patterns
Strategy: validation
Validate before calling
if (skillRegistry == null) { throw new IllegalStateException("SkillRegistry must be created before ReadSkillTool"); }
ReadSkillTool tool = new ReadSkillTool(skillRegistry); Type guard
boolean isReady(SkillRegistry r) { return r != null; } Try / catch
try { tool = new ReadSkillTool(registry); } catch (IllegalArgumentException e) { log.error("Skipped read-skill tool: {}", e.getMessage()); } Prevention
- Create FileSystemSkillRegistry in a dedicated @Bean/initializer so it is never null.
- Only register skill tools when the registry initialized successfully.
- Never forward possibly-null builder results into tool factories.
When it happens
Trigger: Calling new ReadSkillTool(null) or the factory createReadSkillToolCallback(skillRegistry, ...) (same null-arg pattern) with a null registry.
Common situations: Registry creation moved behind an optional feature flag that was off; a builder method returned null on error and the result was passed onward; bean wiring in Spring produced a null dependency.
Related errors
- SkillRegistry cannot be null
- SkillRegistry cannot be null
- 参数 ${parameterName} 的值 ${value} 无法转换为类型 ${type}
- maxConcurrency must be at least 1, but got:
- No default detector for PII type: ${type}
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/9632b62ebceddb8d.
Report an issue: GitHub.