Skip to content

fix(fit): preserve leading U+FEFF in property strings - #8026

Closed
ShuaixinHuang wants to merge 1 commit into
morluto:mainfrom
ShuaixinHuang:codex/fix-fit-string-bom
Closed

ShuaixinHuang wants to merge 1 commit into
morluto:mainfrom
ShuaixinHuang:codex/fix-fit-string-bom

Conversation

@ShuaixinHuang

@ShuaixinHuang ShuaixinHuang commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

FIT property values beginning with U+FEFF lose that character during decoding. For example, algo = "\uFEFFsha256" is reported as sha256, and a matching SHA-256 digest is reported as verified even though the declared algorithm is different. Preserve the exact string and retain unsupported algorithms as unverified.

No associated issue; this was reproduced directly against the production reader and compiled CLI while reviewing existing FIT support.

Problem and expected behavior

The shared property decoder uses TextDecoder's default BOM handling. These are NUL-terminated property values inside a binary container, so the leading character belongs to the property rather than declaring a file encoding. The same loss also changes descriptions, configuration defaults and image references.

Change and scope

Set ignoreBOM: true on the existing shared UTF-8 decoder, retaining fatal UTF-8 validation and all existing string/count bounds. Source regressions cover scalar facts and exact configuration reference identities; compiled CLI regressions distinguish ordinary SHA-256, an unknown prefixed algorithm and U+FEFF-prefixed SHA-256.

This is an ordinary fix within existing read-only FIT inventory/extraction support. No new provider, capability or target-execution authority is introduced; a maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner: FitStructure.ts property decoding; existing reader, inventory, CLI/MCP and comparison consumers use its parsed facts. No downstream normalization or duplicate interpretation is added.
  • CLI/MCP schemas and catalog shape remain unchanged. Unsupported hash identities remain visible with their existing unverified count.
  • Evidence preserves the original property string; default/configuration lookup no longer aliases a different name.
  • Existing file selection, byte ranges, digest checks, extraction ownership and cleanup are unchanged.
  • No generated metadata, package, installer or platform-specific behavior changes.

Expected effects:

  • Read existing files or captured data.

Evidence and regression coverage

Executed on Windows with Node 24.22.1 / npm 11.16.0, based on 1ef5918179d3cb77b8868bd117de662cbd7099ab:

  • Baseline with the new regressions: 2 failed, 52 passed. The source description lost U+FEFF; compiled inspect-artifact reported hash_algorithms: ["sha256"], hashes_verified: 1, hashes_unverified: 0 for the U+FEFF-prefixed declaration. Ordinary SHA-256 and Xsha256 controls passed.
  • Final npm run test:focused -- src/artifacts/fit/FitStructure.test.ts src/artifacts/FitArtifactReader.test.ts tests/acceptance/fitImageCli.test.ts tests/boundary/mcp/fitImageMcp.test.ts tests/acceptance/artifactComparisonFit.test.ts: 81 passed (32 source, 24 reader, 22 compiled CLI, 2 compiled stdio MCP full/compact, 1 comparison). The prefixed declaration now remains "\uFEFFsha256", with 0 verified / 1 unverified.
  • Normal precommit hooks passed for all 3 files; normal prepush typecheck/lint passed 2/2 (cached).
  • Build prerequisites: 3 tasks passed. check:fast: 2/2 passed; standalone knip, knip:production, formatting and metadata checks passed. Typed lint: 0 errors (3,962 warnings).
  • Full npm run check is not green locally: its initial parallel Knip task failed allocating an ArrayBuffer; subsequent standalone Knip passed on both the exact clean baseline and patched tree. The architecture guard also reports backtick-NUL keys in unchanged GuidanceAccess.ts and webCaptureDiff.ts; restoring all three modified files to the exact clean baseline reproduces both architecture errors. All three files were restored byte-for-byte afterward. No gate or resource limit was changed.

Boundary coverage retains malformed UTF-8, unsupported algorithms, digest mismatch, range/overlap, cipher uncertainty, extraction and full/compact MCP controls.

Compatibility, safety, and release

Synthetic FIT fixtures were exercised through real local compiled CLI and stdio MCP. No U-Boot board, external mkimage, or Linux/macOS local verification was performed. No claim of signature authenticity or firmware bootability is made. No migration or release metadata changes.

Author readiness

Human owner: @ShuaixinHuang

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-29T12:09:52.748427Z
We couldn’t complete this review. Comment @codex review to try again.
f3b0255 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

Preserves leading U+FEFF in FIT property strings at the shared decoder, fixing the source of lost characters rather than repairing individual consumers.

  • FIT property strings keep a leading U+FEFF as part of the value.

No actionable issues found. A direct decoder check confirmed the option’s behavior; the repository test suite was not run during this review. Supersession and existing GitHub discussions could not be checked because GitHub authentication was unavailable.

Reviews (1) · Last reviewed commit: "fix(fit): preserve leading U+FEFF in pro..." · Reviewed by Greptile

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants