Repository navigation
fix(artifacts): read artifact descriptions after a UTF-8 BOM - #5577
leninworld wants to merge 2 commits into
Conversation
_describe_artifact_file decoded the file as UTF-8 but kept a leading BOM, so the frontmatter, PowerShell block, Python docstring and comment extractors all missed the metadata of a BOM-saved file. A project override saved with a BOM (Windows PowerShell 5.1, Notepad) then reported no description, and `specify artifact list` showed the hidden core layer's description instead of the override's. Strip one leading BOM after decoding, as CommandRegistrar.parse_frontmatter already does for the script-reference scan in the same module. Assisted-by: OpenAI Codex CLI (model: gpt-5.6-sol, autonomous) Assisted-by: Claude Code (model: Claude Opus 5.5, autonomous)
There was a problem hiding this comment.
🟢 Approval recommended
The narrowly scoped BOM-handling change includes regression coverage for all supported artifact formats and preserves metadata fallback behavior.
No open issues 🎉
What changed in this PR
This pull request fixes artifact description extraction for files saved with a leading UTF-8 BOM, allowing project overrides to report their own metadata while preserving fallback behavior.
Changes:
- Strip one leading BOM before artifact description extraction.
- Add regression coverage for BOM-prefixed command, template, shell, PowerShell, and Python artifacts.
- Verify metadata-free BOM-prefixed overrides still fall back to the hidden layer description.
| File | Description |
|---|---|
| tests/specify_cli/artifacts/test_catalog.py | Adds regression tests covering BOM-prefixed metadata extraction across supported artifact formats and fallback behavior. |
| src/specify_cli/artifacts/catalog.py | Removes one leading UTF-8 BOM before extracting descriptions from on-disk artifact files. |
Review effort: Lite (adaptive)
|
Please address CI/CD errors |
Strip the BOM after the read so the existing read_text call stays unchanged and the FileHelper migration check sees no new direct I/O. Assisted-by: Claude Code (model: Claude Opus 5.5, autonomous) Assisted-by: OpenAI Codex CLI (model: gpt-5.6-sol, autonomous)
|
Thanks. The FileHelper migration check flagged the |
Description
ArtifactCatalogfalls back to on-disk metadata (_describe_artifact_file) when a layer has no manifest description, for example a project override under.specify/templates/overrides/. It decoded the file as UTF-8 but kept a leading UTF-8 BOM, so every extractor missed the metadata: the frontmatter check saw---instead of---, the<# ... #>and"""regexes are anchored at the start, and the comment-line scan saw# .... A BOM-saved override (Windows PowerShell 5.1, Notepad) therefore reported no description, andspecify artifact listshowed the hidden core layer's description instead of the override's.Reproduction on main:
specify init --here --integration claude --ignore-agent-tools --script sh, then save.specify/templates/overrides/speckit.constitution.mdas---\ndescription: Override description\n---\nbody\nand.specify/templates/overrides/scripts/local-sh.shas# Override bash description\necho hi\n.specify artifact list --jsonreported:command:speckit.constitution: the core description (Create or update the project constitution ...)template:speckit.constitution:""script:local-sh:""The same files without the BOM, and these files with this change, report
Override description,Override descriptionandOverride bash description.The fix strips one leading BOM after decoding, as
CommandRegistrar.parse_frontmatteralready does (#5562) for the script-reference scan in the same module. The extractors are unchanged.Testing
Set up this checkout's
.venvand editable install using the local development guide. Run commands from the checkout root.Tested locally with
.venv/bin/specify --help(Windows PowerShell:.\.venv\Scripts\specify.exe --help)Ran relevant existing tests with
.venv/bin/python -m pytest tests -q(Windows PowerShell:.\.venv\Scripts\python.exe -m pytest tests -q); use affected test paths for focused checks andLC_ALL=en_US.UTF-8on macOSTested with a sample project (if applicable)
New tests in
tests/specify_cli/artifacts/test_catalog.py: BOM-saved project overrides (command frontmatter with LF and CRLF, shell comment) report their own description throughlist_artifacts(), and_describe_artifact_filereads a PowerShell block, a Python docstring and template frontmatter after a BOM. These 6 cases fail on main and pass with the fix. Guards that pass on both: the same files without a BOM, and a BOM-saved override with no metadata still falls back to the core description.Full suite with
-n autoon macOS: 17290 passed, 635 skipped, 1 failed:test_version_execution.py::TestWindowsUvToolEnvironment::test_non_windows_uv_tool_dry_run_still_previews_installer, which fails on main in my environment too.uvx ruff@0.15.0 check src tests: all checks passed. pre-commit hooks pass on the changed files.Sample project: the
specify init/specify artifact list --jsonreproduction above, before and after.AI Disclosure
AI disclosure: Claude Code (model: Claude Opus 5.5, autonomous) found the bug while reviewing
artifacts/catalog.py, reproduced it end to end, reviewed and adjusted the tests, ran the tests, lint and hooks, and wrote this description. OpenAI Codex CLI (model: gpt-5.6-sol, autonomous) wrote the fix and tests (code generation) from Claude's task description. The commit carriesAssisted-by:trailers.