Skip to content

[Bug]: InvalidPathException when using default FileSystemSkillRepository on Windows due to illegal character : #842

@xiongbw

Description

@xiongbw

Describe the bug
When creating an AgentSkill object using FileSystemSkillRepository constructor without passing the source field on Windows system, an InvalidPathException is thrown when building the ReActAgent object with .skillBox(skillBox). The exception occurs because the default path contains the illegal character : which is not allowed in Windows file paths.

To Reproduce
Steps to reproduce the behavior:

  1. Create an AgentSkill object without specifying the source field:

    // ...
    // Use FileSystemSkillRepository constructor without source param
    FileSystemSkillRepository repository = new FileSystemSkillRepository(resourcesDir, false);
    AgentSkill skillCreator = repository.getSkill(SKILL_NAME);
    skillBox.registration().skill(skillCreator).apply();
    // ...
    // Exception thrown while creating ReActAgent when loading skillBox.
    ReActAgent agent = ReActAgent.builder()
        .name("agent")
        .model(model)
        .skillBox(skillBox) // Because the skillBox has no source set, and the default value used contains a ':' character.
        .build();
  2. Execute on Windows(You can directly run the AgentSkillExample file on Windows.)

  3. See error
    Expected behavior
    When using the default source field (without passing it explicitly), the ReActAgent should be able to load the SkillBox normally, rather than failing due to illegal path characters. The default source field should be a valid file system path that does not contain characters illegal on Windows systems.

Error messages

Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 24: skill-creator_filesystem:resources_skills
	at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
	at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
	at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
	at java.base/java.nio.file.Path.resolve(Path.java:515)
	at io.agentscope.core.skill.SkillBox.uploadSkillFiles(SkillBox.java:748)
	at io.agentscope.core.ReActAgent$Builder.configureSkillBox(ReActAgent.java:1549)
	at io.agentscope.core.ReActAgent$Builder.build(ReActAgent.java:1379)
	at io.agentscope.examples.quickstart.AgentSkillExample.main(AgentSkillExample.java:102)

Environment:

  • AgentScope-Java Version: 1.0.9
  • Java Version: 17
  • OS: Windows

Additional context
The problematic path is skill-creator_filesystem:resources_skills, where the colon : is an illegal character in Windows file systems, causing the Path.resolve() method to throw an exception. This issue may not occur on Linux/Mac systems as their file systems allow colons in paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions