Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(integrations): escape control characters in SKILL.md frontmatter#3399

Open
marcelsafin wants to merge 1 commit into
github:mainfrom
marcelsafin:fix/3391-skill-frontmatter-quoting
Open

fix(integrations): escape control characters in SKILL.md frontmatter#3399
marcelsafin wants to merge 1 commit into
github:mainfrom
marcelsafin:fix/3391-skill-frontmatter-quoting

Conversation

@marcelsafin

Copy link
Copy Markdown
Contributor

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 \a in 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

  • New module-level yaml_quote() in integrations/base.py: delegates to yaml.safe_dump(default_style='"'), which handles every escape case per spec. Output is byte-identical to the old helper for plain strings.
  • Both copies of the inline _quote helper (base.py skill builder and hermes) now use it, removing the duplicated logic.
  • New regression tests: unit tests for yaml_quote plus integration tests that render SKILL.md from hostile templates and re-parse the frontmatter with yaml.safe_load.

Testing

  • uv run pytest tests/integrations/test_skill_frontmatter_quoting.py — 6 new tests
  • Full suite: 3808 passed, 105 skipped
  • uvx ruff check — clean

Checklist

  • Tests pass locally
  • Lint passes
  • I did use AI assistance for this contribution

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 <[email protected]>
Copilot AI review requested due to automatic review settings July 7, 2026 20:12
@marcelsafin marcelsafin requested a review from mnriem as a code owner July 7, 2026 20:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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() in src/specify_cli/integrations/base.py, delegating escaping/quoting to yaml.safe_dump(default_style='"') to correctly handle newlines and control characters.
  • Replaces the duplicated, hand-rolled _quote implementations in both SkillsIntegration.setup() and the Hermes integration with yaml_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.

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.

SKILL.md frontmatter corrupts multiline descriptions and breaks on control characters

2 participants