mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-11-27 17:00:37 +00:00
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 <willem.jiang@gmail.com>
This commit is contained in:
parent
349540c13f
commit
0890e94e84
@ -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"
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user