Repository navigation
refactor(parsers): report XML, web artifact and Mach-O failures through ParseFailure - #10760
Merged
morluto merged 2 commits intoNov 15, 2026
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Medium impact] The reviewed changes appear safe to merge, with no outstanding actionable findings. SummaryThis PR moves XML, captured web artifact, and Mach-O parser failures onto
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
XML[XML readers] --> Shared[ParseFailureError]
Web[Captured web artifact readers] --> Shared
Macho[Mach-O readers] --> Shared
Shared --> Boundary[Consumer error mapping]
Boundary --> Public[Existing public error categories]
Boundary --> Limits[Reported resource limits]
Boundary --> Fallback[Objective-C names fallback]
Reviews (2) · Last reviewed commit: "refactor(xml): type XML parse failures a..." · Reviewed by Greptile |
morluto
changed the base branch from
refactor/macho-load-command-literals
to
main
November 15, 2026 05:45
morluto
changed the base branch from
main
to
refactor/macho-load-command-literals
November 15, 2026 05:45
morluto
force-pushed
the
refactor/macho-load-command-literals
branch
from
November 15, 2026 05:50
8805d7f to
b111ec9
Compare
morluto
force-pushed
the
refactor/parse-failure-remaining-classes
branch
from
November 15, 2026 05:52
6b6403d to
ca220d5
Compare
22 tasks
12 tasks
morluto
added a commit
that referenced
this pull request
Nov 15, 2026
…gh ParseFailure (#10760) * refactor(parsers): report XML, web artifact and Mach-O failures through ParseFailure * refactor(xml): type XML parse failures as malformed or unsupported only
morluto
added a commit
that referenced
this pull request
Nov 15, 2026
…10714) * refactor(macho): name load-command codes through the shared LC table * refactor(macho): name version-min and string commands through the shared tables * refactor(parsers): report XML, web artifact and Mach-O failures through ParseFailure (#10760) * refactor(parsers): report XML, web artifact and Mach-O failures through ParseFailure * refactor(xml): type XML parse failures as malformed or unsupported only * refactor(parsers): catch per-format document and source failure classes (#10794) * refactor(parsers): report apktool strings and XML plist source failures through ParseFailure * refactor(apktool): drop the unused ParseFailureError import * refactor(parsers): retire the Mach-O, source-map, NDJSON and managed-graph failure classes (#10818) * refactor(parsers): retire the Mach-O, source-map, NDJSON and managed-graph failure classes * refactor(plist): report property-list and keyed-archive failures through ParseFailure (#10822) * refactor(plist): report property-list and keyed-archive failures through ParseFailure * refactor(kuna): report Kuna document failures through ParseFailure (#10824) * refactor(kuna): report Kuna document failures through ParseFailure * test(kuna): pin the limit and malformed facts of Kuna document failures * refactor(plist): report plist decode budgets through ParseFailure (#10842) * refactor(plist): report plist decode budgets through ParseFailure The plist preflight owner throws a ParseFailure limit (plist-decode-bytes) for its byte budget, the shared PlistNestingLimitError for nesting depth, and a malformed failure for a reference cycle, instead of a per-format PropertyListDecodeBudgetFailure whose meaning each caller re-mapped through a fail callback. The fail option, PropertyListDecodeBudgetFailure and interfaceBuilderDecodeBudgetFailure are removed; the parser-format-failure-class baseline reaches zero. * refactor(plist): report keyed-archive allowances as typed limit failures (#10844) keyedArchive.ts and decodeKeyedArchiveBytes throw decodeLimit parse failures (keyed-archive-bytes, -object-table-entries, -values-per-object, -reference-edges) and malformed parse failures instead of plain RangeError/TypeError. KeyedArchiveReader no longer classifies every RangeError as a limit: only a limit parse failure or a host stack/capacity limit is one. The unreachable 128-level scan nesting check is removed; projectPlistValue already refuses the archive first. * test(plist): expect the nesting limit as its ParseFailure carrier * refactor(plist): report plist and NIBArchive input faults through ParseFailure and defects through invariantViolation (#10895) * refactor(plist): report plist and NIBArchive input faults through ParseFailure and defects through invariantViolation * fix(plist): report a cut-short NIB header or plist length record as truncated * fix(native): project the selected Mach-O's parse failures through the shared owner nativeMachoSourcePrimary mapped every non-limit ParseFailureError to AnalysisOutputError, so a malformed or truncated selected Mach-O was reported as unreadable tool output and an unsupported one lost its category. It now uses parseFailureAnalysisError like the ELF, Go and other byte-format providers: malformed and truncated bytes are an invalid path, unsupported bytes an unsupported target, and a limit still falls through to its producer's budget.
morluto
added a commit
that referenced
this pull request
Nov 15, 2026
…10874) * refactor(macho): name load-command codes through the shared LC table * refactor(macho): name version-min and string commands through the shared tables * refactor(parsers): report XML, web artifact and Mach-O failures through ParseFailure (#10760) * refactor(parsers): report XML, web artifact and Mach-O failures through ParseFailure * refactor(xml): type XML parse failures as malformed or unsupported only * refactor(parsers): catch per-format document and source failure classes (#10794) * refactor(parsers): report apktool strings and XML plist source failures through ParseFailure * refactor(apktool): drop the unused ParseFailureError import * refactor(native): select ELF sections through the keyed owner * test(native): pin returned exports and versions for repeated version sections * refactor(nativeaot): read neither of repeated frozen object regions (#10790) * refactor(nativeaot): read neither of repeated frozen object regions through the keyed owner * refactor(parsers): retire every first-match section lookup (#10793) * fix(nativeaot): report an ambiguous frozen object region as partial (#10812) * refactor(native): select program headers and load commands through the keyed owner (#10827) * refactor(native): select the GOT base and dependency segments through the keyed owner (#10847) * refactor(native): select the GOT base and dependency segments through the keyed owner resolveGotBase selects the SHT_DYNAMIC section and the allocated .got.plt/.got sections with uniqueKeyed, so a repeat leaves the GOT base unknown instead of taking the first match; elfDependencies reads PT_LOAD segments through the same keyed program table as PT_DYNAMIC. A new keyed-first-match guard recognizes a find/findLast or filter-then-[0] whose predicate compares a key field, whatever the table is called; existing matches are baselined. The unwind fixture can declare PT_DYNAMIC headers and repeated .dynamic/.got.plt sections. * test(native): pin the PT_DYNAMIC path and destructured keyed lookups The keyed-first-match guard moves to scripts/verify/keyed-first-match.mjs with focused tests, and now recognizes a destructured key in any position and a destructured filter predicate. The single PT_DYNAMIC unwind test declares .dynamic as SHT_PROGBITS so only the program header supplies DT_PLTGOT, and asserts the resolved ranges. * fix(macho): refuse repeated chained-fixup and dyld-info tables (#10850) parseMachoLayout kept the last LC_DYLD_CHAINED_FIXUPS range and merged the rebase/bind streams of every LC_DYLD_INFO(_ONLY) command. A repeat now refuses the slice as malformed. NativeMachoInspection's chained import-name reader already declined repeated LC_DYLD_CHAINED_FIXUPS; that rule is now covered by a test. * refactor(parsers): retire the Mach-O, source-map, NDJSON and managed-graph failure classes (#10818) * refactor(parsers): retire the Mach-O, source-map, NDJSON and managed-graph failure classes * refactor(plist): report property-list and keyed-archive failures through ParseFailure (#10822) * refactor(plist): report property-list and keyed-archive failures through ParseFailure * refactor(kuna): report Kuna document failures through ParseFailure (#10824) * refactor(kuna): report Kuna document failures through ParseFailure * test(kuna): pin the limit and malformed facts of Kuna document failures * refactor(plist): report plist decode budgets through ParseFailure (#10842) * refactor(plist): report plist decode budgets through ParseFailure The plist preflight owner throws a ParseFailure limit (plist-decode-bytes) for its byte budget, the shared PlistNestingLimitError for nesting depth, and a malformed failure for a reference cycle, instead of a per-format PropertyListDecodeBudgetFailure whose meaning each caller re-mapped through a fail callback. The fail option, PropertyListDecodeBudgetFailure and interfaceBuilderDecodeBudgetFailure are removed; the parser-format-failure-class baseline reaches zero. * refactor(plist): report keyed-archive allowances as typed limit failures (#10844) keyedArchive.ts and decodeKeyedArchiveBytes throw decodeLimit parse failures (keyed-archive-bytes, -object-table-entries, -values-per-object, -reference-edges) and malformed parse failures instead of plain RangeError/TypeError. KeyedArchiveReader no longer classifies every RangeError as a limit: only a limit parse failure or a host stack/capacity limit is one. The unreachable 128-level scan nesting check is removed; projectPlistValue already refuses the archive first. * test(plist): expect the nesting limit as its ParseFailure carrier * fix(verify): count a filter index only on the filter's own result * refactor(macho): select slices through one owner with typed refusals * refactor(keyed): select FIT properties and certificate extensions through uniqueKeyed * refactor(keyed): key each FIT node once, pin repeated FIT properties and subjectKeyIdentifiers, and type the unknown Mach-O header as unsupported * refactor(plist): report plist and NIBArchive input faults through ParseFailure and defects through invariantViolation (#10895) * refactor(plist): report plist and NIBArchive input faults through ParseFailure and defects through invariantViolation * fix(plist): report a cut-short NIB header or plist length record as truncated * fix(native): project the selected Mach-O's parse failures through the shared owner nativeMachoSourcePrimary mapped every non-limit ParseFailureError to AnalysisOutputError, so a malformed or truncated selected Mach-O was reported as unreadable tool output and an unsupported one lost its category. It now uses parseFailureAnalysisError like the ELF, Go and other byte-format providers: malformed and truncated bytes are an invalid path, unsupported bytes an unsupported target, and a limit still falls through to its producer's budget.
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
parser-format-failure-classguard still counted four per-format failure classes that restate theParseFailurealgebra (malformed / truncated / unsupported / limit) under their own names:XmlDocumentParseError,WebArtifactFormatFailure,MachoBinaryFormatErrorandUnsupportedMachoMetadataFormatError. Each needed its own catch-site translation. This PR moves them ontoParseFailureErrorand, with #10664 merged, lowers the counted baseline to zero ("parser-format-failure-class": {}).Refs the W7 parser-kernel workstream (structural audit report 06). Stacked on #10714, which edits the same two Mach-O files.
Problem and expected behavior
No user-visible behavior change is intended. Public error categories, messages, reported limits and recovery text are the same.
Change and scope
src/domain/xmlDocument.ts: ill-formed XML ismalformed(formatxml, the saxes/DOM error as cause). A refused DOCTYPE or internal subset isunsupportedwithfield: "doctype"/"internal-subset". Consumers readkindinstead of the privatereason:SazMetadata(DOCTYPE staysunsupported),AndroidManifestComponents(same limitation text throughfield ?? kind).src/browser/assets/WebArtifactReads.ts: invalid UTF-8 and invalid JSON in a captured web artifact throwmalformedInput("captured-web-artifact", …); the failure mapper matches amalformedParseFailureErrorwhere it matched the private class. Sameformat/invalid_formatoutcomes.src/native/MachoCommandNames.ts,NativeMachoSelectedSlice.ts: framing failures throwmalformedInput("macho", …)(a short read istruncatedInput).MachoCommandNamesLimitErrornow extendsParseFailureError<"limit">with a named limit (macho_load_command_<unit>) and keeps itsmaximumandunit, whichinspect_machoreports.NativeMacOSProviderandKunaInventoryPlacementcatch the shared algebra.src/native/AppleMachoSelection.ts: 32-bit and big-endian PowerPC64 Mach-O metadata throwBinaryFormatFailure("unsupported", …, { undecodedContent: true }): the image holds metadata this reader cannot decode.AppleDispatchMetadatamapsundecodedContentto the same capability-unavailable refusal as before (so the ObjC class fallback still runs);Il2cppBinaryImagealready maps anyunsupportedfailure tounsupported-containerand loses its special case.Not included:
ApktoolStringsDocumentError,XmlPlistSourceError(extendsTypeError),CaptureFormatErrorandElfPointerRelocationFailure(refactor(elf): report pointer relocation failures through ParseFailure #10748). Widening the pattern is a separate step.Contribution scope: ordinary refactor within existing boundaries; not applicable.
Contract and boundary impact
Semantic owner and earliest changed stage:
src/domain/parseFailure.tsowns the failure algebra; the XML, web artifact and Mach-O load-command producers now throw it, and their catch sites readkind/undecodedContentinstead of private classes. Four private classes are deleted.Contribution scope fit and linked maintainer decision: W7 plan, parser failure algebra; not applicable.
CLI and MCP/tool-catalog contract: unchanged.
Provider, bridge, target-format, or platform compatibility: unchanged.
NativeMacOSProvidernow reports any non-limitParseFailureErroron theinspect_macho/list_architecturessource path as the output error it used forMachoBinaryFormatError; no other producer on that path throws one today.Evidence, artifact, provenance, or reconstruction contract: unchanged.
Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
Generated metadata, package, or installation impact: none.
Read existing files or captured data.
Launch or attach to a process.
Inject instrumentation or run scripts/code.
Change process memory, registers, files, or configuration.
Contact network services.
Recover protected code or work around protections.
Documentation or usability only; no target interaction.
Not sure yet; investigation or maintainer guidance needed.
Evidence and regression coverage
Tests added or updated:
xmlDocument.test.tsassertskindand the DOCTYPEfield;objcClassMetadataFallback.test.tsandAppleMachoSelection.test.tsassert the 32-bit / PowerPC64 failures areunsupportedwithundecodedContent: trueand that an unsupported CPU type or unknown magic is not;keyedArchiveXmlSyntax.test.tsandApktoolDecodeOutput.test.tsassert the XML cause is amalformedParseFailureError.Base reproduction or other evidence: source-derived; the existing provider tests (
nativeProvider,nativeDispatchFormatFailures,webArtifactReadOwnership,il2cppMetadataProvider,NativeMachoSourceProvider,SazMetadata) pin the unchanged public outcomes.User-visible CLI/MCP output (if applicable): unchanged.
Remaining proof gaps: none known.
Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run test:focused -- src/domain/xmlDocument.test.ts src/native/MachoCommandNames.test.ts src/native/NativeMachoSourceProvider.test.ts src/browser/history/SazMetadata.test.ts src/native/AppleMachoSelection.test.ts src/apktool/ApktoolDecodeOutput.test.ts tests/boundary/filesystem/keyedArchiveXmlSyntax.test.ts tests/boundary/providers/native/objcClassMetadataFallback.test.ts tests/boundary/providers/native/nativeDispatchFormatFailures.test.ts tests/boundary/filesystem/webArtifactReadOwnership.test.ts tests/boundary/il2cpp/il2cppMetadataProvider.test.ts tests/boundary/providers/native/nativeProvider.test.ts— 12 files, 332 tests passed (after updating the namespace-invalid XML assertion tokind).node scripts/verify/architecture-guards.mjs --shrink-baselines: passed; fourparser-format-failure-classentries removed. After rebasing onto the rebased refactor(macho): name load-command codes through the shared LC table #10714 (with refactor(python): report pyc format failures through ParseFailure #10664 merged), the baseline is{}andnode scripts/verify/architecture-guards.mjspasses.npm run check:fast— typecheck and lint passed.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.