From 97657239b15208c70a6cfbb6a85ce99bd2132d69 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sun, 4 Oct 2026 11:27:14 +0530 Subject: [PATCH] test(skills): decode bundled files exactly like skill_view r2 quality Low: bundled_skill_texts skipped any file that failed a strict UTF-8 decode, but skill_view's _read_skill_text reads with encoding="utf-8-sig", errors="replace" and never raises, so a file with one stray byte is still served to the model while the guard skipped it. Read every file the same way and drop the try/except; the helper becomes a list comprehension. --- .../test_bundled_skill_doc_placeholders.py | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/tests/skills/test_bundled_skill_doc_placeholders.py b/tests/skills/test_bundled_skill_doc_placeholders.py index 703e397efe..227805e191 100644 --- a/tests/skills/test_bundled_skill_doc_placeholders.py +++ b/tests/skills/test_bundled_skill_doc_placeholders.py @@ -19,19 +19,14 @@ ROLE_TAG = re.compile("<" + "/?(?:tool|system|assistant)" + ">", re.IGNORECASE) def bundled_skill_texts() -> list[tuple[Path, str]]: - # skill_view serves ANY file under a skill root that decodes as UTF-8 text, whatever its - # suffix, so scan everything and skip only what fails that same strict decode. - texts = [] - for root in ("skills", "optional-skills", "plugins"): - if not (REPO_ROOT / root).is_dir(): - continue - for path in sorted((REPO_ROOT / root).rglob("*")): - if not path.is_file() or ".hub" in path.parts: - continue - try: - texts.append((path, path.read_text(encoding="utf-8"))) - except UnicodeDecodeError: - continue + # skill_view serves ANY file under a skill root, whatever its suffix, decoded via + # _read_skill_text (utf-8-sig, errors="replace"), so scan everything the same way. + texts = [ + (path, path.read_text(encoding="utf-8-sig", errors="replace")) + for root in ("skills", "optional-skills", "plugins") + for path in sorted((REPO_ROOT / root).rglob("*")) + if path.is_file() and ".hub" not in path.parts + ] assert texts, "bundled skills tree not found under skills/, optional-skills/ or plugins/" return texts