Skip to content

fix: accept UTF-8 BOM in bundler JSON readers - #5557

Merged
mnriem merged 4 commits into
github:mainfrom
chelsealong:fix/codex-spec-kit-5556
Nov 25, 2026
Merged

mnriem merged 4 commits into
github:mainfrom
chelsealong:fix/codex-spec-kit-5556

Conversation

@chelsealong

@chelsealong chelsealong commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #5556. Bundler JSON readers accept one leading UTF-8 BOM while preserving non-ASCII text and U+FEFF inside JSON strings. Doubled or misplaced BOMs, malformed JSON, and duplicate catalog keys still raise BundlerError. load_json() retains its path.open() behavior.

A regression test exercises specify bundle catalog add and offline bundle search with a BOM-prefixed catalog. It failed on the original source and passes with this change. A symlink regression fails with the FileHelper read and passes with the restored file open.

Testing

  • .venv/bin/specify --help
  • .venv/bin/python -m pytest tests/specify_cli/bundles -q — 1,326 passed
  • Ruff check and git diff --check
  • Catalog add/search exercised through a sample project test fixture
  • FileHelper migration guard source scan against the PR base

AI Disclosure

  • I did use AI assistance

AI disclosure: Codex (GPT-6), autonomous executor; reasoning effort was not exposed. Codex authored the code and tests and ran the reported checks. No human review or testing is claimed.

@chelsealong
chelsealong requested a review from mnriem as a code owner November 24, 2026 17:06
Copilot AI adaptive review requested due to automatic review settings November 24, 2026 17:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the change adding support for a single leading UTF-8 BOM in JSON readers.

No open issues 🎉

What changed in this PR

Fixes #5556 by allowing bundler JSON readers to accept a single leading UTF-8 BOM, supporting catalogs created with Windows PowerShell 5.1.

Changes:

  • Handles a leading BOM in file-based and string-based JSON readers while preserving Unicode content.
  • Adds coverage for valid BOM-prefixed input and rejection of invalid input.
  • Adds a catalog add/offline search regression test.

Before-and-after regression results are reported in the PR; they were not rerun here.

File Description
tests/​specify_cli/​bundles/​test_yamlio.py Tests BOM handling, Unicode preservation, and invalid-input rejection.
tests/​specify_cli/​bundles/​catalog/​test_command_add.py Tests adding and searching a BOM-prefixed catalog.
src/​specify_cli/​bundles/​yamlio.py Accepts one leading BOM in both JSON readers.

Review effort: Balanced (adaptive)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the change enabling bundler JSON readers to accept a single leading UTF-8 BOM.

No open issues 🎉

Review effort: Balanced

@mnriem

mnriem commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Please fix CI/CD errors

Copilot AI balanced review requested due to automatic review settings November 24, 2026 17:40
@chelsealong

Copy link
Copy Markdown
Contributor Author

Updated load_json to read through FileHelper while retaining UTF-8 BOM handling and the existing JSON and read-error messages. The migration scanner flags file-path.open at the current PR head and finds no direct read in this patch. Validation: 1,322 bundle tests passed; Ruff, git diff --check, and specify --help passed. CI on the current PR head still shows the original migration-boundary failure and has not rerun with this patch.

On behalf of chelsealong: Codex (GPT-6) autonomously authored this change and reply and ran the listed checks; reasoning effort was not exposed. No human review or testing is claimed.

Commit: f7b13b5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed to evaluate missing test coverage for invalid BOMs and BOM-prefixed malformed JSON in load_json’s separate on-disk decoding path.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the change supporting BOM-prefixed catalog JSON.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 24, 2026 17:51
@chelsealong

Copy link
Copy Markdown
Contributor Author

Added load_json file-based tests for doubled and misplaced BOMs and malformed JSON after a valid BOM. Each raises BundlerError with the Invalid JSON message. Validation: 14 focused tests and all 1,325 bundle tests passed; Ruff, specify --help, and git diff --check passed. The PR’s CI matrix is still running.

On behalf of chelsealong: Codex (GPT-6) autonomously authored the tests and this reply and ran the listed checks; reasoning effort was not exposed. No human review or testing is claimed.

Commit: 555d0d9

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Switching load_json to FileHelper’s scoped filesystem backend changes symlink confinement and platform-specific access semantics beyond BOM decoding, requiring human compatibility review.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The BOM fix also replaces ordinary file opening with FileHelper's scoped, platform-specific reads, changing filesystem and handle assumptions that warrant human review.

No open issues 🎉

Review effort: Balanced

@mnriem

mnriem commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the BOM fix and the regression coverage. Could we keep the existing path.open() call in load_json() and strip exactly one leading BOM from the decoded text before parsing? I verified that this passes the FileHelper migration guard without changing how bundle records and integration metadata are opened. Switching to FileHelper adds Windows file-sharing requirements, and a read failure during integration detection is treated as “no active integration.” I’d keep this PR focused on BOM handling and review the filesystem migration separately.

AI disclosure: GitHub Copilot (GPT-6.2 Sol, interactive mode) reviewed the patch, checked the migration guard, and drafted this comment on behalf of @mnriem, who authorized posting.

Copilot AI balanced review requested due to automatic review settings November 25, 2026 00:12
@chelsealong

Copy link
Copy Markdown
Contributor Author

Updated load_json() to keep path.open() and strip exactly one leading BOM after UTF-8 decoding. Added a regression test showing that a symlinked JSON file outside the immediate parent remains readable; it failed before the change and passes now. All 1,326 bundle tests pass, as do Ruff, specify --help, git diff --check, and a migration guard source scan against the PR base.

On behalf of chelsealong: Codex (GPT-6, autonomous mode; reasoning effort not exposed) authored the change, test, and this reply and ran the reported checks. No human review or testing is claimed.

Commit: 22ae96e

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change allowing shared JSON readers to accept a single leading UTF-8 BOM.

No open issues 🎉

Review effort: Balanced

@mnriem mnriem added the triage-must-have Verdict: high-value, important work for Spec Kit — do first label Nov 25, 2026
@mnriem
mnriem requested a balanced review from Copilot November 25, 2026 14:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change allowing the bundler’s JSON readers to accept a single leading UTF-8 BOM.

No open issues 🎉

Review effort: Balanced

@mnriem
mnriem merged commit 542a297 into github:main Nov 25, 2026
14 checks passed
@mnriem

mnriem commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage-must-have Verdict: high-value, important work for Spec Kit — do first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: bundler JSON readers reject UTF-8 BOM from PowerShell 5.1 catalogs

3 participants