Files
reverse-engineering-anything/docs/reference/target-failures.md
T
a61ff39c9a fix(errors)!: refuse malformed SQLite, pwntools and EVM inputs as target failures (#14268)
* feat(errors)!: add the TargetFailure model, its projection table and conformance registry

Introduce one domain-owned TargetFailure value whose kind alone derives
the public code, category, retryability, recovery and details, for CLI
and MCP alike. Selected-file malformed and truncated refusals are the
first area on it: AnalysisMalformedTargetError is replaced by
AnalysisTargetFailureError, and ParseFailure's byte-structure variants
are TargetFailure variants rather than a parallel type.

The shared stableArtifactParserFailureCli loop is replaced by a
declarative registry (tests/support/targetFailure/readers/*.ts) and one
generated suite that runs every registered case through the CLI and MCP.

BREAKING CHANGE: selected-file malformed and truncated refusals add
details.failure_kind, and a truncated target's remediation now says to
re-acquire the complete file instead of choosing another target. Codes
are unchanged. Affected operations: every operation that refuses a
selected file's malformed or truncated bytes, including the ELF, PE,
Mach-O, DWARF, Go, Rust, BEAM, pyc, devicetree, Apple IPS, kernel
module, binary hardening, managed PE/CLI and IL2CPP readers.

* test(managed): name the target failure error in the merged status test

* docs(reference): name the error CSV instead of linking a non-page file

* fix(tests): expect the path reason for non-regular dyld inputs

#14225 refuses a non-regular dyld input as ArtifactReaderFailure("path");
dylibFileLifetime still expected "format" and fails on main's shard 9.

* fix(tests): expect io, invariant and path where #14225 reclassified

stableArtifact expected "format" for an impossible descriptor byte count
(now io) and an invalid chunk size (now InternalInvariantError);
directoryArtifactReaderOpen expected "format" for a non-file entry (now
path, the same change as #14238). All three fail on main.

* fix(errors)!: raise container reader byte faults as malformed or truncated targets

Delete the ambiguous `format` reason from ArtifactReaderFailure and
ArtifactOperationError. Each container reader now raises its owner's
fact once, through malformedArtifact / truncatedArtifact, with format,
offset, field and measured extents. Short reads inside a measured extent
are read-coverage integrity failures, path-kind refusals are `path`,
foreign or recovery-requiring inputs are `unsupported`, host tool output
is `io`, and REA defects are InternalInvariantError.

The trace, NTFS journal, release exposure, web capture, native macOS and
web artifact adapters project the reader's parsed facts as
AnalysisTargetFailureError instead of invalid_request. Inventory
malformed, truncated, unsupported and cancelled reasons take their code
from the TargetFailure projection table, so a truncated container is
unsupported_target with failure_kind "truncated" on both paths.

BREAKING CHANGE: inventory_artifact, inspect_artifact, extract_artifact,
analyze_javascript_application, inspect_desktop_application,
inspect_keyed_archive, inspect_asset_catalog, inspect_nuget_nupkg,
trace_dylib_resolution, trace_web_module_imports and
trace_web_source_location report damaged container bytes as
unsupported_target (details.reason "malformed" or "truncated", with
failure_kind and format) instead of artifact_operation_failed with
reason "format", and a truncated container as unsupported_target instead
of truncated. inspect_playwright_trace, inspect_ntfs_journal,
audit_release_exposure, the web capture inspection operations and the
caller-selected import and source maps report damaged selected bytes as
unsupported_target instead of invalid_request. The `format` reason no
longer appears in details.reason.

* test(artifacts): expect target failure codes in compiled CLI and MCP suites

* fix(errors)!: refuse malformed SQLite, pwntools and EVM inputs as target failures

The SQLite engine's `format` reason is renamed to `malformed` at its
owner (SQLITE_INSPECTION_REASONS), and its refusal becomes an
AnalysisTargetFailureError at the selected path with format "sqlite".
The pwntools and EVM worker replies keep their wire reason "format",
which their workers define, and the adapters translate it once into a
malformed target failure with the profile's format (elf, elf-core,
evm-bytecode) instead of an invalid_format argument issue. SQLite joins
the target-failure conformance registry.

BREAKING CHANGE: inspect_sqlite_database, inspect_binary_layout,
inspect_recorded_crash and inspect_evm_interface report a selected
file's malformed bytes as unsupported_target with details.failure_kind
"malformed", format_failure, format and path, instead of invalid_request
with an invalid_format issue on path.

* fix(errors): give the integrity kind a schema-valid code and list the reference page

artifact_integrity_mismatch's projection schema requires declared and
calculated digests, which a TargetFailure of kind integrity does not
carry, so the kind now projects artifact_operation_failed with category
integrity_mismatch. The model test validates every kind's projection
against analysisErrorProjectionSchema. The reference page joins the
documentation sidebar.

* fix(artifacts): report a short carrier read as a changed file and keep unsupported desktop probes local

A Bun or Node SEA short read inside a range already checked against the
measured size meant the file changed, not that it was truncated. The
carrier range reader and Bun's readExact now raise read-coverage
integrity for it, and keep 'outside the file' as the truncated case.
DesktopFileInspection records an unsupported managed-metadata probe as a
row issue again, so later file checks still run.

* test(errors): expect target failure facts in the pwntools and EVM reply suites

The literal-replacement scenario now reads the failure's detail instead
of an issues[] message, and a malformed reply wrapped by cleanup failure
reports category unsupported_target.

* test(errors): register PE DOS-signature and truncated IPS refusals and drop their per-command copies

The non-MZ PE imports and load-config cases (PE32/PE32+, ZZ and high-bit
signatures) and the truncated Apple IPS body move into the conformance
registry, which runs them through the CLI and MCP and now also checks
that a refusal leaves the selected file unchanged. The per-command tests
keep only their valid-image controls.

* test(sqlite): drop the malformed-database provider test the conformance registry covers

inspect_sqlite_database/not-a-database in the target-failure registry runs
the same non-SQLite bytes through the CLI and MCP, asserts the malformed
target facts and checks the selected file is unchanged.

* feat(errors)!: make failure_kind the identifier and derive code and retry from it

Apply the owner review on #14239 to the TargetFailure model:
- remove details.format_failure; failure_kind is the only identifier;
- give integrity, conflict and io their own codes
  (target_integrity_mismatch, input_conflict, host_io_failed) and derive
  inventory malformed, truncated and unsupported codes from the same table;
- add a retry hint (none, backoff, after_change) derived from the kind,
  with io refined by its transient errno fact; retryable stays the
  unchanged-retry flag and is true exactly for backoff;
- rename the limit-cut result code and category truncated to partial;
- drop cancelled and resource from the target kinds and spell
  identifiers in American English (unrecognized);
- return a target failure a tool handler throws as a projected isError
  result instead of letting the SDK flatten it to text.

BREAKING CHANGE: details.format_failure is removed (read
details.failure_kind). The truncated result code and category are now
partial. Target integrity failures report target_integrity_mismatch,
host read failures host_io_failed and disagreeing inputs input_conflict.
Inventory operations (inventory_artifact, inspect_artifact,
extract_artifact and the other inventory callers) report truncated
container bytes as unsupported_target. Every target failure carries a
top-level retry hint.

* test(sqlite): expect a malformed target for non-database bytes in the CLI suite

* fix(artifacts): keep changed-file short reads, invalid offsets and EOF declarations apart

PyInstaller reads inside the measured size, and .NET bundle manifest
refills, now raise read-coverage integrity on a zero-byte read instead of
truncated. A .NET bundle field and a Godot PCK directory entry that extend
past the file are truncated (with offset and extents) instead of
malformed. An absent or invalid ASAR packed offset is malformed; only a
valid range past the archive is truncated. The .NET manifest string
offset is reported in file coordinates.

* fix(pwntools): report a short ELF header as a truncated target

The layout and recorded-crash workers raise a distinct truncated reason
when the file ends inside the ELF identification or header, and the
decoder projects it as failure_kind truncated instead of inferring it
from the message.

* fix(artifacts): verify the carrier before blaming a short read on the bytes

The NTFS $MFT decoder, positional members (FIT, uImage, Bun, Deno) and
.NET bundle members now re-verify the source before reporting a short
stream as malformed, so a file that changed during the read reports the
change. The truncation site builds the model's measured extent.

* docs(android): name unsupported_target for truncated boot image structures

* fix(errors)!: report a target that changed during the read as failure_kind changed

Inventory integrity failures whose check means the target moved under the
read (container, member and unpacked-entry identity, read coverage,
traversal coverage) now take the model's changed projection: code
artifact_changed, retry backoff and details.failure_kind changed. A
selected target that no longer matches the one the session admitted gets
its own admitted-identity check and keeps its reopen recovery.

BREAKING CHANGE: inventory_artifact, inspect_artifact, extract_artifact and
the other inventory operations report a target that changed during the
read as artifact_changed (retryable, failure_kind changed) instead of
artifact_operation_failed. Admission-identity refusals report
integrity_check admitted-identity instead of container-identity.

* test(artifacts): expect admitted-identity for selections replaced before admission

A selected source replaced before admission fails the admitted-identity check rather than container-identity since the changed/admitted split.

* test(go): name the fixture and result when an MZ carrier is not refused through MCP

* test(verify): expect target failures for damaged ELF, core and EVM inputs in real-provider verifiers

The binary-layout, recorded-crash and EVM verifiers still expected invalid_input for malformed or truncated selected bytes. The pwntools and EVM adapters now report those as unsupported_target with failure_kind; a missing path remains invalid_input.

* test(web): expect the partial code for a refused source-map admission

The limit-cut code is partial; this Windows-lane test arrived from main with the old truncated spelling.

* test(errors): check the MCP target failure as the text clients receive

The stdio transport removes the private structured carrier from every isError result, so the conformance suite asserted a field that never reaches clients and failed every case. The projected diagnostic is checked from the JSON text instead.

* test(artifacts): expect artifact_changed when selected bytes change after inventory

Bundle resources replaced after open and unselected JavaScript sources rewritten after inventory now fail a change check, so they report artifact_changed with retry backoff rather than artifact_operation_failed.

* fix(errors): report a session digest mismatch as admitted-identity

The digest the session admitted does not change when the same request is
repeated, so targetDigestChangedFailure was inviting a backoff retry that
fails the same way. It now names admitted-identity, which stays
artifact_operation_failed and not retryable, and tells the caller to reopen.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(artifacts): classify unused PyInstaller compressed input as layout

zlib stops at the first complete stream, so a declared span that arrives
intact but is not fully consumed is trailing junk or a second stream, not
a file that changed. A source that ends before that span stays read-coverage.
The cached-carrier test replaces the file with a different size so a shared
timestamp cannot hide the rewrite.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* test(applications): expect unsupported_target for a damaged trace stream

A trace member whose CRC fails is a malformed zip target. The partial
Evidence assertion now checks that code, failure_kind and format.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* test(dylib): expect admitted-identity when the opened target is replaced

The session keeps the digest it admitted, so replacing the executable and
repeating trace_dylib_resolution is not a retryable container change.

Co-authored-by: morluto <morluto@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
2026-11-24 21:54:08 -05:00

8.4 KiB

Target failures

When REA cannot read a target, details.failure_kind identifies why. It is the primary machine identifier, in the sense of an RFC 9457 problem type. code is a coarse class derived from it, and retry says whether repeating the request can help. Clients should branch on failure_kind and must not parse message, remediation.action or details.reason.

Kinds

failure_kind Meaning code category retry What to do
selection The request names something that is not a valid target for this operation. invalid_request invalid_input after_change Fix the request.
unrecognized No reader for this operation recognizes the bytes. unsupported_target unsupported_target none Choose another operation or provider.
unsupported A recognized format, but in a version or variant this reader does not implement. unsupported_target unsupported_target none Choose another operation or provider.
malformed The bytes break the format's own rules. unsupported_target unsupported_target none Choose another target, or a well-formed copy.
truncated The bytes end before a structure they declare. unsupported_target unsupported_target none Re-acquire the complete file.
integrity The bytes contradict a digest or checksum they declare. target_integrity_mismatch integrity_mismatch none Get a fresh copy, or keep the observed bytes with integrity_policy=record-and-continue where it is offered.
conflict Two or more inputs each parse, but disagree. None is blamed. input_conflict invalid_input after_change Select inputs that belong together.
changed The file changed while it was read. artifact_changed integrity_mismatch backoff Retry once it is stable.
access Host permissions denied the read. access_denied unavailable after_change Grant read access.
io The host could not read the file. host_io_failed execution_failure backoff (transient errno) or none Retry with backoff for a transient error. Otherwise check the device and file.

The four target refusals share unsupported_target because the caller cannot use the target as it stands, and each needs a different target or tool. failure_kind says which. No other code covers more than one kind.

The list of kinds can grow. Handle the kinds you know, and treat any other kind by its code.

Inventory operations report a container, member or read range that changed during the read as changed, with details.integrity_check naming the check (container-identity, member-identity, unpacked-entry-identity, read-coverage or traversal-coverage). A selected target that no longer matches the one the session opened (integrity_check: admitted-identity) is not changed: reopen the target instead of repeating the request.

A caller's cancellation (cancelled) and an admission limit (resource_constraint) describe the operation, not the target, so they keep their own error shapes. A result cut short by a delivery or decode limit reports code partial. truncated names only a target whose bytes end early.

Retry

retry Meaning
none Repeating the request cannot help. The target itself must change.
backoff The unchanged request may succeed later. Retry with backoff.
after_change Only a changed request, input or host permission can succeed.

retryable keeps the meaning it has across all REA errors: the unchanged request may succeed. For a target failure, it is true exactly when retry is backoff.

Details

Every target failure reports:

  • operation: the operation that refused the target.
  • path: the exact file at fault. For a composite request, this is the input whose bytes failed. For a conflict, it is the primary input, and inputs lists all of them.
  • failure_kind: the kind.
  • format: the format whose owner established the failure, such as elf, macho or pe-cli.
  • reason: the owner's description, for people.
  • offset and field: where the failure is, when the owner knows.
  • partial_observation: the file's size and SHA-256, when the operation hashed the file before it refused it.

Some kinds add facts:

  • truncated reports available_bytes and required_bytes when the owner measured them.
  • conflict reports inputs, a list of { field, path } entries, one for each input that disagrees. The CLI spells each field the way the command spells its option.

MCP delivery

A target failure is always a tools/call result with isError: true, and its projection is the JSON text block. It is never a JSON-RPC error. A provider that throws a target failure inside a tool handler still produces this result.

Migration

This model replaces details.format_failure with failure_kind. It also changes these codes:

  • the truncated code to partial;
  • artifact_operation_failed to target_integrity_mismatch or host_io_failed;
  • invalid_request to input_conflict, for a pair of inputs that disagree.

The remaining operations move to this vocabulary area by area, and each release note lists the operations whose code changes. The plan is tracked in #14239.

Container and inventory readers (ZIP, ASAR, PyInstaller, .NET bundles, Node SEA, Deno and Bun standalones, Godot PCK, UnityFS, wxapkg, FIT, uImage, iNES, Android OTA payloads, ESP images, NTFS $MFT streams, firmware record files and others) now report damaged bytes as malformed or truncated, with the reader's format. Before, they reported artifact_operation_failed with details.reason: "format". Two other things changed:

  • The Playwright trace, NTFS journal, release exposure and web capture operations report a damaged selected file as unsupported_target, not invalid_request.
  • inspect_sqlite_database, inspect_binary_layout, inspect_recorded_crash and inspect_evm_interface also report a damaged selected file as unsupported_target (failure_kind: "malformed", with format sqlite, elf, elf-core or evm-bytecode), not invalid_request.
  • A short read after REA measured the file is now an integrity failure with details.integrity_check: "read-coverage" (the file changed during the read), not a format error.

Related: settings, limits and recovery for limit failures, and docs/user-visible-errors.csv for every error case and its code.