Skip to content

fix(nacos-skill): handle block-sequence arrays in SKILL.md frontmatter#1445

Open
sunwg2 wants to merge 9 commits into
agentscope-ai:mainfrom
sunwg2:fix/skills
Open

fix(nacos-skill): handle block-sequence arrays in SKILL.md frontmatter#1445
sunwg2 wants to merge 9 commits into
agentscope-ai:mainfrom
sunwg2:fix/skills

Conversation

@sunwg2

@sunwg2 sunwg2 commented May 20, 2026

Copy link
Copy Markdown

Nacos exports use multi-line - item syntax for array fields. The old normalizer concatenated items into an invalid scalar, causing SnakeYAML to throw "sequence entries are not allowed here in 'string'".

Collect - item lines into a list and emit them as an inline YAML array ["a", "b"]; strip YAML quoting from raw items via unquoteYamlString().

Closes #1438

AgentScope-Java Version

[The version of AgentScope-Java you are working on, e.g. 1.0.12, check your pom.xml dependency version or run mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)]

Description

Fix #1438NacosSkillRepository crashes with
sequence entries are not allowed here in 'string' when a SKILL.md
exported from Nacos uses YAML block-sequence syntax for array fields
such as trigger_intents.

normalizeFoldedFlatYaml() was designed to fold indented continuation
lines back into the previous key's value. It had no awareness of YAML
block-sequence entry lines (- item), so it treated them as plain
continuation text and concatenated all items into a single invalid scalar:

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@sunwg2 sunwg2 requested a review from a team May 20, 2026 03:01
@CLAassistant

CLAassistant commented May 20, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@LearningGp

Copy link
Copy Markdown
Member
image

@AgentScopeJavaBot AgentScopeJavaBot added bug Something isn't working area/ext/integration External protocols & middleware integrations labels May 28, 2026
Nacos exports use multi-line `- item` syntax for array fields. The old
normalizer concatenated items into an invalid scalar, causing SnakeYAML
to throw "sequence entries are not allowed here in 'string'".

Collect `- item` lines into a list and emit them as an inline YAML array
`["a", "b"]`; strip YAML quoting from raw items via unquoteYamlString().

Closes agentscope-ai#1438
@sunwg2

sunwg2 commented May 29, 2026

Copy link
Copy Markdown
Author

recheck

@AgentScopeJavaBot AgentScopeJavaBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 AI Review

This PR fixes Bug #1438 by adding support for YAML block-sequence arrays (- item) in SKILL.md frontmatter within the Nacos skill repository. When NacosSkillRepository normalizes Nacos-exported YAML for the downstream MarkdownSkillParser, block-sequence entries under a key with no inline value are now collected into a list and serialized as an inline YAML array. The implementation is clean and well-scoped with four integration tests covering multi-item, single-item, special-character, and mixed scalar/array scenarios. No critical or blocking issues were found.

char last = value.charAt(value.length() - 1);
if (first == '"' && last == '"') {
String inner = value.substring(1, value.length() - 1);
return inner.replace("\\\"", "\"").replace("\\\\", "\\");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[nit] The double-quoted unescape in unquoteYamlString only handles \" and \\. Other valid YAML double-quoted escape sequences (\n, \t, \uXXXX, etc.) pass through as literal characters. The Javadoc should note this is an intentional subset.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point. Updated the Javadoc to explicitly note that only " and \ are unescaped — other YAML double-quoted escape sequences (\n, \t, unicode escapes, etc.) pass through as literal characters, and this is an intentional subset covering the Nacos export format.

assertFalse(repository.delete("any-skill"));
}

// -------- Bug #1438: multi-line block-sequence array in frontmatter --------

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[nit] The test suite covers double-quoted and unquoted list items but has no test for single-quoted values (e.g., - 'value with ''apostrophe'''). Adding a test case would exercise the single-quote branch of unquoteYamlString.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch. Added testGetSkillWithSingleQuotedArrayItems to cover the single-quote branch of unquoteYamlString, including a case with '' (escaped apostrophe) to verify it unescapes correctly to '.

sunwg2 added 6 commits June 5, 2026 20:06
…oted array test

Address review comments on PR agentscope-ai#1445:
- Clarify in Javadoc that only backslash-quote and double-backslash are unescaped in double-quoted mode; other YAML escape sequences (e.g. \n, \t, unicode escapes) pass through as literals. This is an intentional subset covering the Nacos export format.
- Add testGetSkillWithSingleQuotedArrayItems to exercise the single-quote branch of unquoteYamlString, including the apostrophe unescape case ('' -> ').
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ext/integration External protocols & middleware integrations bug Something isn't working

Projects

None yet

4 participants