Repository navigation
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…so a delimiter inside a value ended the frontmatter early: a description was cut short, a quoted value failed to parse, and every key after a `|` block scalar was dropped. Locate the delimiter by line instead, as YAML does, and accept CRLF and CR line breaks. Fixes google#7725.
bb9d98c to
faaa549
Compare
|
Closing this as superseded: #7726 landed the same fix on For the record, I verified the landed implementation against the cases I had written tests for — a Thanks @alphasafal for the quick turnaround on #7725. |
Description
Fixes #7725.
_parse_skill_md_contentsplit SKILL.md withcontent.split("---", 2), so thefrontmatter ended at the first occurrence of
---anywhere in the filerather than at the closing delimiter line. Any
---inside a frontmatter valuetherefore truncated the frontmatter:
description: Compare two options --- pros, cons and a verdict.loaded asCompare two options, and the tail plus the real closing delimiter leakedinto
instructions. The model then chooses skills from a truncateddescription.
description: "Draft release notes --- never publish them."failed to loadwith
Invalid YAML in frontmatter: while scanning a quoted scalar, althoughthe file is valid.
description: |block scalars holding a---rule line dropped every keyafter them (
license,metadata,allowed-tools, includingmetadata.adk_additional_tools) silently, since the parser never saw them.Because directory, zip, GCS and
SkillToolsetloading all go through this onefunction, every loader was affected.
The fix
_split_frontmatternow locates the delimiters by line, which is howYAML itself delimits a document:
---(trailing whitespacetolerated).
---,so a
---indented inside a block scalar stays content, per YAML's rule thatblock content is indented past its key.
\r\n,\ror\n, so a file saved withforeign line endings parses exactly like an LF one.
Error messages are unchanged, so callers matching on them keep working, and the
public
load_skill_*API andFrontmattermodel are untouched.Testing plan
Unit tests added in
tests/unittests/skills/test__utils.py:test_frontmatter_value_may_contain_delimiter(3 cases)---inside a valuetest_frontmatter_block_scalar_may_contain_delimiter_linedescription: |with a---line, keys after it preservedtest_body_may_start_with_delimiter_linetest_frontmatter_tolerates_foreign_line_endings(\r\n,\r)test_parse_skill_md_content_requires_the_delimiter_linestest__load_skill_from_zip_bytes_keeps_delimiter_in_valueBefore/after evidence (same test selection, source reverted vs. patched):
Full suites, Windows 11 / Python 3.13, runtime deps only:
The 13 failures are identical before and after the change (verified with a
sorted failure-set diff). They are environment-bound: 12 GCS tests need
google-cloud-storage, andtest__load_skill_from_dircomparesfile://URIspellings that differ on Windows.
tests/unittests/tools/test_skill_toolset.py+test_skill_path_traversal.py:5 failed, 336 passed; the 5 failures are shell-symlink tests that cannot runin this sandbox, unrelated to frontmatter parsing.
Lint/format:
pyink --check,isort --check-only,ruff checkall clean onthe two touched files.
Notes for reviewers
moved.
concern: a UTF-8 BOM before
---still fails to load, and a lone---name: xheader (no newline) is now rejected rather than mis-parsed.Happy to file follow-ups if you want them.