Repository navigation
fix: ignore UTF-8 BOM in FileSystemSkillStore files - #13745
Conversation
A SKILL.md that starts with a UTF-8 byte order mark was treated as having no frontmatter, so warm_up() raised a ValueError about a missing description. Bundled text files kept the BOM as a leading U+FEFF. Read SKILL.md and bundled text files with utf-8-sig, which drops a leading BOM and reads BOM-less UTF-8 unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@Assertive-xxh is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
1AbdullahButt
left a comment
There was a problem hiding this comment.
Looks correct. Here's what I checked.
- These are the only three text reads in the store.
skill_store.py:135,:199and:256were the onlyread_textcalls inhaystack/skill_stores/.SkillToolset(tools/skills/skill_toolset.py) reads nothing itself and goes through the store, sowarm_up()on the toolset is covered too. The PDF and image branches still useread_bytes(), so a BOM-like prefix in a binary file isn't touched. - The cause is as described.
b'\xef\xbb\xbf---\n'.decode('utf-8')keeps'---', andstr.lstrip()doesn't removeU+FEFF. Solines[0]in_parse_frontmatter(:42) isn't---, and the function returns{}. Withutf-8-sig, the same bytes decode to'---'. AU+FEFFin the middle of a file is kept (b'a\xef\xbb\xbfb'gives'ab'), so only a leading BOM is dropped. - Error handling is unchanged.
utf-8-sigraises the sameUnicodeDecodeErrorfor non-UTF-8 bytes, so theexceptatread_skill_filestill turns a Latin-1 or other binary file into the "not a readable asset"ValueError. - The tests reach the right code.
write_text(..., encoding="utf-8-sig")writes a real BOM, and the first test goes through bothwarm_up(vialist_skills) andload_skill. git merge-treeagainstmainis clean.
I didn't run the tests.
Reviewed with help from Claude Code.
davidsbatista
left a comment
There was a problem hiding this comment.
Thanks! - out of curiosity, did you find this while using your own SKILLS?
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the review and for merging! Not while using them, no. I came across it in a test rather than in real use: I was going through the skill store code with an AI assistant, saw that #12726 had fixed BOM handling in the converters, and tried a After your question I also ran it against the skills I actually use with Claude Code and Codex on Windows (19 skills, CRLF line endings). None of them starts with a BOM, and all 19 load fine both before and after this change, so I would not have hit it with that set. |
Related Issues
FileSystemSkillStorereports a missingdescriptionfor aSKILL.mdthat starts with a UTF-8 BOM #13744Proposed Changes:
FileSystemSkillStorereadSKILL.mdand bundled text files withencoding="utf-8", which keeps a UTF-8 byte order mark (BOM) as a leadingU+FEFF._parse_frontmatterstrips whitespace and then expects the first line to be---, butstr.lstrip()does not stripU+FEFF. ASKILL.mdsaved with a BOM was therefore treated as having no frontmatter, andwarm_up()raisedValueError: Skill '...' is missing a 'description' in its frontmatter.for a file that has a description. One such file breaks the whole skills directory, includingSkillToolset.warm_up().read_skill_filereturned bundled text files with a leading.The three
read_textcalls (warm_up,load_skill,read_skill_file) now useutf-8-sig, which drops a leading BOM and reads UTF-8 without a BOM unchanged. This is the same approach as #12726 for the text, CSV, Markdown and JSON converters.How did you test it?
test/skill_stores/file_system/test_skill_store.py:test_list_and_load_skill_ignore_utf8_bomandtest_read_skill_file_strips_utf8_bom. With the source frommain(4b4346b) both fail (2 failed, 34 passed); on this branch the file passes.pytest test/skill_stores test/tools -m "not integration": 365 passed, 2 skipped, 12 deselected (Ubuntu 24.04 on WSL2, Python 3.12.3).ruff check,ruff format --check,mypy,scripts/release_note_backticks.py --check,codespell.reno lint(my clone is shallow), the license header check. I used a plain virtual environment with the base dependencies instead of the Hatchtestenvironment, and ran the checks above directly rather than throughpre-commit.Notes for the reviewer
read_skill_fileis included because it has the same cause. Without it a bundled text file with a BOM reaches the model with a leading. I can drop that part if you prefer a narrower change.U+FEFFin the middle of a file, and UTF-16, Latin-1 or binary files behave as before; I comparedmainand this branch on those cases. The one difference I found: a bundled file that consists only of an incomplete BOM (the two bytesEF BB) now reads as an empty string instead of raising "not a readable asset".docs-website/docs/tools/skilltoolset.mdx, since it does not mention encodings. The class docstring now states that files are read as UTF-8 and that a leading BOM is ignored. Happy to add a sentence to the page if you want one.Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.🤖 Generated with Claude Code