[GH-ISSUE #583] YAML frontmatter fails when SKILL.md contains control characters and quoted strings #280

Open
opened 2026-06-05 17:21:26 -04:00 by yindo · 0 comments
Owner

Originally created by @zhengyuzi on GitHub (Jun 4, 2026).
Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/583

Problem Description

When a skill's SKILL.md file contains invisible control characters (e.g. Windows CRLF \r\n, stray \r, UTF-8 BOM \uFEFF) and the YAML frontmatter includes quoted strings (using either single or double quotes), the SkillsMiddleware fails to parse the skill and throws the following error:

Invalid YAML in <skill-path>: YAMLParseError: Unexpected scalar at node end

Key Observations

  • Triggers when: Any quoted string (single-quoted or double-quoted) is present in the YAML frontmatter.
  • Works fine when: Using unquoted plain text values (e.g., description: plain text) even with control characters present.
  • Temporary workaround: Removing invisible control characters (normalizing line endings, stripping BOM) makes parsing succeed for quoted strings.

Proposed Fix

In parseSkillMetadataFromContent, sanitize the frontmatter string before calling yaml.parse:

const cleanFrontmatter = frontmatterStr
  .replace(/\uFEFF/g, '')      // remove UTF-8 BOM
  .replace(/\r/g, '')          // remove all carriage returns (both stray and from CRLF)
  // Optional: remove other ASCII control characters (preserve \n and \t)
  .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, '');

frontmatterData = yaml.parse(cleanFrontmatter);
Originally created by @zhengyuzi on GitHub (Jun 4, 2026). Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/583 ## Problem Description When a skill's `SKILL.md` file contains **invisible control characters** (e.g. Windows CRLF `\r\n`, stray `\r`, UTF-8 BOM `\uFEFF`) and the YAML frontmatter includes **quoted strings** (using **either single or double quotes**), the `SkillsMiddleware` fails to parse the skill and throws the following error: ``` Invalid YAML in <skill-path>: YAMLParseError: Unexpected scalar at node end ``` ## Key Observations - **Triggers when**: Any quoted string (single-quoted or double-quoted) is present in the YAML frontmatter. - **Works fine when**: Using unquoted plain text values (e.g., `description: plain text`) even with control characters present. - **Temporary workaround**: Removing invisible control characters (normalizing line endings, stripping BOM) makes parsing succeed for quoted strings. ## Proposed Fix In `parseSkillMetadataFromContent`, sanitize the frontmatter string before calling `yaml.parse`: ```typescript const cleanFrontmatter = frontmatterStr .replace(/\uFEFF/g, '') // remove UTF-8 BOM .replace(/\r/g, '') // remove all carriage returns (both stray and from CRLF) // Optional: remove other ASCII control characters (preserve \n and \t) .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, ''); frontmatterData = yaml.parse(cleanFrontmatter); ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#280