Skip to content

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

Done

Description

@adityajai119

Bug Description

Bundler JSON readers reject a UTF-8 byte-order mark (BOM). json.load() and
json.loads() in src/specify_cli/bundles/yamlio.py use plain utf-8, so a
leading U+FEFF becomes a literal character that json rejects with
"Unexpected UTF-8 BOM (decode using utf-8-sig)". The failure reaches every
bundler JSON path: load_json() (bundle records and .specify/integration.json),
loads_json() (catalog payloads from local files, file:// URLs, HTTPS fetches,
and packaged snapshots), and therefore specify bundle catalog add /
specify bundle search.

Windows PowerShell 5.1 writes a BOM by default for
ConvertTo-Json ... | Set-Content -Encoding UTF8, so catalogs authored with the
documented Windows tooling are unusable. The same applies to any editor that
saves JSON as "UTF-8 with BOM".

Steps to Reproduce

  1. Initialize a Spec Kit project and write a catalog with Windows PowerShell 5.1:
    $obj | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath team-catalog.json -Encoding UTF8
  2. Confirm the file starts with EF BB BF.
  3. Run specify bundle catalog add team-catalog.json.
  4. Run specify bundle search demo --offline --json.
  5. Alternatively, add a leading U+FEFF to .specify/bundle-records.json or
    .specify/integration.json and run any command that reads them.

Expected Behavior

A leading UTF-8 BOM is decoded and ignored exactly once; the rest of the JSON,
including non-ASCII values and an intentional U+FEFF inside a string, is parsed
normally. Malformed JSON, a doubled BOM, a non-leading BOM, and duplicate keys
still produce a BundlerError.

Actual Behavior

Error: Invalid JSON from ...: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0); catalog add/search exits 1 and records cannot load.

Specify CLI Version

1.4.4 (current main, commit e59953d)

AI Agent

opencode

Operating System

Windows 11 (Windows PowerShell 5.1 end-to-end reproduction)

Python Version

3.14.7

Error Logs

Error: Invalid JSON from team-catalog.json: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)

AI Disclosure

  • Agent / tool: OpenCode
  • Model: Gemini 4 Neon
  • Settings / mode: autonomous on behalf of adityajai119
  • Extent: AI reproduced the failure with a regression test, identified the root
    cause in the shared JSON helpers, wrote the fix, and ran the verification
    commands.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions