alibaba/spring-ai-alibaba · error · IllegalArgumentException

Skill name cannot be null or empty

Error message

Skill name cannot be null or empty

What it means

readSkillContent(name) rejects a null or empty skill name with IllegalArgumentException before attempting any lookup. The registry requires an explicit, non-empty identifier to resolve a skill on the filesystem, so blank names are treated as programmer error rather than a lookup miss.

Source

Thrown at spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/skills/registry/filesystem/FileSystemSkillRegistry.java:235

	 */
	public String getProjectSkillsDirectory() {
		return projectSkillsDirectory;
	}

	/**
	 * Get the user skills directory path.
	 * This is an implementation-specific method, not part of the SkillRegistry interface.
	 *
	 * @return the user skills directory path
	 */
	public String getUserSkillsDirectory() {
		return userSkillsDirectory;
	}

	@Override
	public String readSkillContent(String name) throws IOException {
		if (name == null || name.isEmpty()) {
			throw new IllegalArgumentException("Skill name cannot be null or empty");
		}

		// Get the skill by name
		Optional<SkillMetadata> skillOpt = get(name);
		if (skillOpt.isEmpty()) {
			throw new IllegalStateException("Skill not found: " + name);
		}

		SkillMetadata skill = skillOpt.get();

		// Use the normal loadFullContent method for filesystem skills
		return skill.loadFullContent();
	}

	@Override
	public String getSkillLoadInstructions() {
		List<SkillMetadata> skills = listAll();
		List<SkillMetadata> userSkills = new ArrayList<>();

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Ensure a non-empty name is passed; validate before calling
  2. Check where the name comes from (config, user input) and fix the empty source
  3. Use Optional or a contains(name) check first to avoid null/empty calls

Example fix

// before
registry.readSkillContent(skillName);
// after
if (skillName != null && !skillName.isEmpty()) {
    String content = registry.readSkillContent(skillName);
}
Defensive patterns

Strategy: validation

Validate before calling

if (name == null || name.isEmpty()) { throw new IllegalArgumentException("skill name required"); }

Type guard

boolean isValidName(String s) { return s != null && !s.isEmpty(); }

Try / catch

try { content = registry.readSkillContent(name); } catch (IllegalArgumentException e) { log.warn("Invalid skill name", e); }

Prevention

When it happens

Trigger: Calling readSkillContent(null), readSkillContent("") directly, or indirectly when a caller (e.g. a test like disableHidesSkillFromReadsAndSearch or a tool/skill loader) passes a name sourced from an unset config property, empty map lookup, or uninitialized variable.

Common situations: Skill name loaded from YAML/config that is missing or empty; result of a search/filter that returned no name; variable never initialized before invoking the registry.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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