From 0890e94e8467d168c90c32a735493e0106c27bb7 Mon Sep 17 00:00:00 2001 From: ZephyrWang <152375907+Wang-Zephyr@users.noreply.github.com> Date: Fri, 27 Nov 2026 08:42:22 +0800 Subject: [PATCH] fix(skill-review): report invalid YAML timestamp values (#8695) * fix(skill-review): report invalid YAML timestamp values * Handle malformed explicit YAML timestamps in skill frontmatter --------- Co-authored-by: Willem Jiang --- .../harness/deerflow/skills/frontmatter.py | 5 +++- backend/tests/test_skill_review_core.py | 30 +++++++++++++++++++ docs/guide/skills-and-tools.md | 2 ++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/backend/packages/harness/deerflow/skills/frontmatter.py b/backend/packages/harness/deerflow/skills/frontmatter.py index b4ff2b86e4..b4866b4c1a 100644 --- a/backend/packages/harness/deerflow/skills/frontmatter.py +++ b/backend/packages/harness/deerflow/skills/frontmatter.py @@ -57,8 +57,11 @@ def split_skill_markdown(content: str) -> tuple[SkillMarkdownParts | None, str | frontmatter_text = match.group(1) try: metadata = yaml.safe_load(frontmatter_text) - except yaml.YAMLError as exc: + except (yaml.YAMLError, ValueError) as exc: return None, f"Invalid YAML in frontmatter: {exc}" + except AttributeError: + # PyYAML's explicit timestamp constructor assumes its pattern matched. + return None, "Invalid YAML in frontmatter: invalid scalar value" if not isinstance(metadata, dict): return None, "Frontmatter must be a YAML dictionary" diff --git a/backend/tests/test_skill_review_core.py b/backend/tests/test_skill_review_core.py index 7c9be8d739..0b2fa3c705 100644 --- a/backend/tests/test_skill_review_core.py +++ b/backend/tests/test_skill_review_core.py @@ -788,6 +788,36 @@ def test_cli_reports_non_string_frontmatter_key_without_crashing(tmp_path, capsy assert "Unknown frontmatter field(s): 42, unexpected-field" in output +@pytest.mark.parametrize( + "updated, valid", + [ + ("2026-02-30", False), + ("2026-11-26T25:00:00Z", False), + ("!!timestamp 2026-11-26T13:45:00+08:0", False), + ("2026-11-26", True), + ("!!timestamp 2026-11-26T13:45:00+08:00", True), + ('"2026-02-30"', True), + ], +) +def test_cli_reports_invalid_yaml_timestamp_as_frontmatter_finding(tmp_path, capsys, updated, valid): + from deerflow.skills.validation import validate_skill_frontmatter_text + + content = _valid_skill().replace("allowed-tools: []", f"metadata:\n updated: {updated}") + _write(tmp_path / "SKILL.md", content) + + exit_code = review_cli_main([str(tmp_path), "--format", "json", "--fail-on", "blocker"]) + facts = json.loads(capsys.readouterr().out) + + _validate_contract("review_facts.v1.schema.json", facts) + assert exit_code == (0 if valid else 1) + invalid_frontmatter = [finding for finding in facts["findings"] if finding["rule_id"] == "structure.invalid-frontmatter"] + assert bool(invalid_frontmatter) is not valid + if not valid: + assert invalid_frontmatter[0]["severity"] == "blocker" + assert invalid_frontmatter[0]["path"] == "SKILL.md" + assert validate_skill_frontmatter_text(content)[0] is valid + + def test_cli_fail_on_incomplete_package(tmp_path, capsys): _write(tmp_path / "SKILL.md", _valid_skill()) _write(tmp_path / "references" / "large.md", "x" * 32) diff --git a/docs/guide/skills-and-tools.md b/docs/guide/skills-and-tools.md index e18dd2afe4..f4f33e59d3 100644 --- a/docs/guide/skills-and-tools.md +++ b/docs/guide/skills-and-tools.md @@ -456,6 +456,8 @@ cd backend uv run python -m deerflow.skills.review.cli ../skills/public/data-analysis --format text --fail-on error --fail-on-incomplete ``` +Invalid YAML dates or timestamps in frontmatter produce a `structure.invalid-frontmatter` blocker in the review report. Quote a date-like metadata value if it is intended as literal text. + Public-skill CI waivers are exact, expiring exceptions in `.github/skill-review-waivers.v1.json`. Because only the trusted base manifest can suppress a finding, a file-changing pull request can be preauthorized safely by first merging a manifest-only change that lists the reviewed future full-file SHA-256 in `preapproved_file_sha256s`; the file change can then land in a later pull request. Tools follow the same philosophy. DeerFlow comes with a core toolset — web search, web fetch, rendered web capture, file operations, bash execution — and supports custom tools via MCP servers and Python functions. The bundled DDG, Brave, Tavily, SearXNG, and Serper search providers accept an optional `time_range` of `day`, `week`, `month`, or `year`; omitting it preserves existing search behavior. For DDG recency searches, DeerFlow excludes DDGS backends that ignore time limits. Swap anything. Add anything.