Skip to content

fix(skill): Remove Windows reserved characters from FileSystemSkillRepository source (#947)#1031

Merged
LearningGp merged 7 commits intoagentscope-ai:mainfrom
huangxinchuan:fix/issue-947-windows-path
Mar 26, 2026
Merged

fix(skill): Remove Windows reserved characters from FileSystemSkillRepository source (#947)#1031
LearningGp merged 7 commits intoagentscope-ai:mainfrom
huangxinchuan:fix/issue-947-windows-path

Conversation

@huangxinchuan
Copy link
Copy Markdown
Contributor

Problem

On Windows systems, FileSystemSkillRepository.buildDefaultSourceSuffix() generates source strings containing Windows reserved characters (e.g., C: drive colon), causing InvalidPathException when AgentScope tries to
create files or directories with these names.

Error example from #947:
java.nio.file.InvalidPathException: Illegal char <:> at index 25: kafka-sampling_filesystem:.agents_skills

Solution

Remove all Windows reserved characters (\, /, :, *, ?, ", <, >, |) from the generated source suffix using regex replacement.

Changes

  • Modified buildDefaultSourceSuffix() in FileSystemSkillRepository.java
  • Added regex to strip Windows reserved characters from the source string

Testing

  • Existing test testSave_SourceHasNoColon now passes on Windows
  • The fix is backward compatible (non-Windows systems unaffected)

Fixes #947


@huangxinchuan huangxinchuan requested a review from a team March 24, 2026 03:43
@cla-assistant
Copy link
Copy Markdown

cla-assistant bot commented Mar 24, 2026

CLA assistant check
All committers have signed the CLA.

@cla-assistant
Copy link
Copy Markdown

cla-assistant bot commented Mar 24, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


黄新传 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@huangxinchuan huangxinchuan force-pushed the fix/issue-947-windows-path branch from 820548c to 31452b1 Compare March 24, 2026 03:47
…pository source

Fixes agentscope-ai#947

The buildDefaultSourceSuffix() method in FileSystemSkillRepository generated source
strings containing Windows reserved characters (like : from C:\ drive), causing
InvalidPathException on Windows.

This fix removes all Windows reserved characters (\/:*?\"<>|) from the source suffix
to ensure Windows path compatibility.
@huangxinchuan huangxinchuan force-pushed the fix/issue-947-windows-path branch from 2b78e0b to 24d3a0d Compare March 24, 2026 04:01
@huangxinchuan
Copy link
Copy Markdown
Contributor Author

@cla-assistant recheck

I have updated the commit author from company email to my personal GitHub email (87484734@qq.com).

The old commits with "黄新传 643160@ky-tech.com.cn" have been force-pushed and replaced.
Please recheck the CLA status for the current commits.

Thanks!

@huangxinchuan
Copy link
Copy Markdown
Contributor Author

Hi @AlbumenJ and team,

This PR is ready for review. It fixes the Windows path compatibility issue reported in #947.

Summary of changes:

  • FileSystemSkillRepository: Remove Windows reserved characters (\ / : * ? " < > |) from the generated source suffix
  • GitSkillRepository: Change source prefix from git: to git- and apply the same character filtering
  • Added comprehensive unit tests for both repositories

Verification:

The fix ensures that skill repository sources don't contain Windows reserved characters, which previously caused InvalidPathException when running on Windows systems.

Please let me know if you need any changes or have questions. Thanks for your time!

@huangxinchuan huangxinchuan force-pushed the fix/issue-947-windows-path branch 2 times, most recently from 57eea67 to db8dad5 Compare March 24, 2026 04:58
…y source

Related to agentscope-ai#947

GitSkillRepository also generates source strings with Windows reserved characters
(like 'git:owner/repo' containing colon). This commit:
1. Changes default source format from 'git:' to 'git-' prefix
2. Adds regex filter to remove Windows reserved characters from branch names
3. Updates tests to reflect the new format

This ensures consistency with FileSystemSkillRepository fix.
@huangxinchuan huangxinchuan force-pushed the fix/issue-947-windows-path branch from db8dad5 to 009655b Compare March 24, 2026 05:04
Fix code style to comply with Spotless check requirements.
- Relax assertions in testClone_RepositoryNotFound to handle various CI environment error messages
- Strengthen testClone_InvalidUrl assertions to verify non-empty message
- Add more error pattern matches for network-related failures

This improves test reliability across different CI environments with varying network conditions.
Add System.out.println statements to print actual vs expected source values.
This will help identify the discrepancy in CI environment.
…ard slash

The regex pattern for removing Windows reserved characters incorrectly
included forward slash (/), which caused owner/repo format to become
ownerrepo.

Changes:
1. Remove forward slash from the regex pattern in buildDefaultSource()
2. Keep forward slash as it's valid in source identifiers (owner/repo format)
3. Improve comments to clarify why forward slash is preserved
4. Minor improvement to extractRepositoryIdentifier() for clarity

Fixes test failure: expected <git-test/repo> but was <git-testrepo>

Related to agentscope-ai#947
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...cope/core/skill/repository/GitSkillRepository.java 60.00% 0 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@LearningGp
Copy link
Copy Markdown
Collaborator

@fang-tech PTAL

Copy link
Copy Markdown
Contributor

@fang-tech fang-tech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

- Revert unnecessary Windows reserved character filtering in FileSystemSkillRepository
  (the : character issue was already fixed by using filesystem- prefix)
- Change replaceAll to use "-" instead of "" in GitSkillRepository for clarity
- Remove corresponding test case that was testing the reverted behavior

Addressing review comments from @fang-tech:
- FileSystemSkillRepository.java:171 - The character filtering was redundant since
  the source prefix already uses "-" instead of ":"
- GitSkillRepository.java:344 - Replace reserved chars with "-" for better clarity
@LearningGp LearningGp merged commit 3ee94ae into agentscope-ai:main Mar 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]:java.nio.file.InvalidPathException: Illegal char <:> at index 25

3 participants