crewAIInc/crewAI · error · ValueError
No YAML frontmatter block found
Error message
No YAML frontmatter block found
What it means
The fallback frontmatter parser (used when the SDK's `crewai.skills.parser` is not importable) looks for a `^---\n...\n---` block at the very start of the file. If the regex does not match — no delimiters, a leading blank line/BOM, CRLF line endings, or `---` not on line 1 — it raises `ValueError("No YAML frontmatter block found")`, which surfaces as error 70's message.
Source
Thrown at lib/cli/src/crewai_cli/skills/main.py:398
"""Extract YAML frontmatter fields from a SKILL.md string.
Reuses crewai.skills.parser when available, with a minimal
fallback for environments where the full SDK isn't installed.
"""
try:
from crewai.skills.parser import parse_frontmatter
fm_dict, _ = parse_frontmatter(content)
return fm_dict
except ImportError:
pass
# Fallback: minimal YAML parsing without SDK dependency
import re
match = re.match(r"^---\n(.*?)\n---", content, re.DOTALL)
if not match:
raise ValueError("No YAML frontmatter block found")
try:
import yaml
return yaml.safe_load(match.group(1)) or {}
except ImportError:
result: dict[str, str] = {}
for line in match.group(1).splitlines():
if ":" in line:
key, _, value = line.partition(":")
result[key.strip()] = value.strip()
return result
def _read_version(self, skill_md: Path) -> str | None:
"""Read the version from a SKILL.md file's metadata, or None."""
try:
fm = self._parse_frontmatter(skill_md.read_text(encoding="utf-8"))
raw_metadata = fm.get("metadata")
if isinstance(raw_metadata, dict):View on GitHub (pinned to 754d7323be)
Solutions
- Ensure SKILL.md starts with `---` on the very first byte, ends the block with a second `---`, and uses LF line endings (`dos2unix SKILL.md`).
- Install/upgrade the crewai SDK so the more robust `parse_frontmatter` is used instead of the strict regex fallback.
- Remove any BOM: `sed -i '1s/^\xEF\xBB\xBF//' SKILL.md`.
Example fix
# before --- name: x --- (body) # after --- name: x --- (body)
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
import re
def frontmatter_block_at_start(path: str = "SKILL.md") -> bool:
raw = Path(path).read_bytes()
if raw.startswith(b"\xef\xbb\xbf"):
return False # BOM breaks the regex
return bool(re.match(rb"^---\n.*?\n---", raw, re.DOTALL)) Prevention
- Save SKILL.md with LF line endings and no BOM (UTF-8 plain).
- Put `---` on the very first line; no leading blank lines.
- Install the crewai SDK so the robust parser is used instead of the strict fallback regex.
When it happens
Trigger: Calling `_parse_frontmatter` (via `crewai skill publish`) on a SKILL.md that does not begin with `---\n`; a UTF-8 BOM before the first `---`; Windows CRLF line breaks; or frontmatter delimiters written as `----`. The SDK parser is bypassed only when the crewai SDK package is absent.
Common situations: Files saved on Windows with CRLF; editors that insert a BOM; manually authored SKILL.md missing delimiters; older CLI installs without the SDK installed so the fallback path runs.
Related errors
- Failed to parse SKILL.md frontmatter: {exc}
- SKILL.md frontmatter must include a 'name' field.
- SKILL.md frontmatter must include a 'version' field before p
- Unable to read --definition path {definition_path}: {exc}
- Directory {skill_dir} already exists.
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/e9fdd82e2214d72f.
Report an issue: GitHub.