Skip to content

Read case/hash-list JSON as utf-8-sig so a BOM doesn't break import - #3

Merged
charpy4n6 merged 1 commit into
abrignoni:mainfrom
charpy4n6:fix/vic-json-utf8-bom
Sep 2, 2026
Merged

charpy4n6 merged 1 commit into
abrignoni:mainfrom
charpy4n6:fix/vic-json-utf8-bom

Conversation

@charpy4n6

Copy link
Copy Markdown
Collaborator

Some Project VIC exporters (and some hash-list tools) write the JSON as UTF-8 with a byte-order mark. Python's json rejects a leading BOM with "JSONDecodeError: Unexpected UTF-8 BOM", so importing such a file failed outright.

Switch every JSON/text read on the import path from encoding="utf-8" to "utf-8-sig", which strips a leading BOM when present and is a no-op otherwise:

  • projectvic.load / projectvic.is_vic_file
  • case.parse_source_spec (GLEAPP ingest-job spec)
  • hashdb.import_hashset (Project VIC JSON branch and the CSV/TSV branch)

Tests: _make_vic now writes its fixture with a BOM so the whole VIC suite exercises this, plus test_projectvic_json_with_bom asserting a BOM-prefixed file is detected and parsed.

Claude-Session: https://claude.ai/code/session_01VcEhYD7XkWcxocYPALdcEb

Some Project VIC exporters (and some hash-list tools) write the JSON as
UTF-8 with a byte-order mark. Python's json rejects a leading BOM with
"JSONDecodeError: Unexpected UTF-8 BOM", so importing such a file failed
outright.

Switch every JSON/text read on the import path from encoding="utf-8" to
"utf-8-sig", which strips a leading BOM when present and is a no-op
otherwise:

  - projectvic.load / projectvic.is_vic_file
  - case.parse_source_spec (GLEAPP ingest-job spec)
  - hashdb.import_hashset (Project VIC JSON branch and the CSV/TSV branch)

Tests: _make_vic now writes its fixture with a BOM so the whole VIC
suite exercises this, plus test_projectvic_json_with_bom asserting a
BOM-prefixed file is detected and parsed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VcEhYD7XkWcxocYPALdcEb
@charpy4n6
charpy4n6 merged commit 33008f9 into abrignoni:main Sep 2, 2026
@charpy4n6
charpy4n6 deleted the fix/vic-json-utf8-bom branch September 2, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant