fix(integrations): escape control characters in SKILL.md frontmatter#3399
Open
marcelsafin wants to merge 1 commit into
Open
fix(integrations): escape control characters in SKILL.md frontmatter#3399marcelsafin wants to merge 1 commit into
marcelsafin wants to merge 1 commit into
Conversation
yaml.safe_dump with default_style='"' replaces the hand-rolled quote helpers in base.py and hermes, so newlines and control characters in template descriptions round-trip instead of producing unparseable YAML. Fixes github#3391 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes SKILL.md frontmatter generation for skills-based integrations by ensuring descriptions (and other frontmatter values) are emitted as valid, single-line, double-quoted YAML scalars even when the source contains newlines or control characters (per issue #3391).
Changes:
- Introduces
yaml_quote()insrc/specify_cli/integrations/base.py, delegating escaping/quoting toyaml.safe_dump(default_style='"')to correctly handle newlines and control characters. - Replaces the duplicated, hand-rolled
_quoteimplementations in bothSkillsIntegration.setup()and the Hermes integration withyaml_quote(). - Adds regression tests to verify round-tripping of multiline and control-character descriptions, including end-to-end SKILL.md generation and YAML frontmatter parsing.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/integrations/test_skill_frontmatter_quoting.py | Adds regression coverage for yaml_quote() and for generated SKILL.md frontmatter round-tripping hostile descriptions. |
| src/specify_cli/integrations/hermes/init.py | Switches Hermes SKILL.md frontmatter quoting to yaml_quote() to avoid invalid YAML for multiline/control characters. |
| src/specify_cli/integrations/base.py | Adds yaml_quote() and applies it to SkillsIntegration’s SKILL.md frontmatter generation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3391
SkillsIntegration.setup()and the hermes skill builder quoted SKILL.md frontmatter values with a hand-rolled helper that only escaped\and". A template description containing a newline or a control character (for example a YAML escape like\ain the source frontmatter, which parses to a real control byte) produced a broken or lossy SKILL.md: the newline split the quoted scalar across lines and the control byte was emitted raw, which is invalid in double-quoted YAML.Changes
yaml_quote()inintegrations/base.py: delegates toyaml.safe_dump(default_style='"'), which handles every escape case per spec. Output is byte-identical to the old helper for plain strings._quotehelper (base.py skill builder and hermes) now use it, removing the duplicated logic.yaml_quoteplus integration tests that render SKILL.md from hostile templates and re-parse the frontmatter withyaml.safe_load.Testing
uv run pytest tests/integrations/test_skill_frontmatter_quoting.py— 6 new testsuvx ruff check— cleanChecklist