From 3e01e71cbb4c3838be1fcde4f78cd37caca68145 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Tue, 24 Nov 2026 21:59:40 -0500 Subject: [PATCH] fix(errors)!: report managed coverage gaps and IL2CPP pair conflicts as target failures (#14272) * 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(errors)!: report managed coverage gaps and IL2CPP pair conflicts as target failures Managed readers interpret an issue code once, in managedIssueTargetFailure: a coverage gap is an unsupported target, every other rule violation is a malformed target, and the inventory metadata status is derived from that same fact. managedInspectionTargetFailure now returns only AnalysisTargetFailureError. An IL2CPP binary that parses but does not link to its metadata is a conflict target failure that lists both inputs and blames neither, in place of an invalid_request with two issue entries. Metadata version 108 is an unsupported target. The CLI spells each conflict input's field by the command's option name. BREAKING CHANGE: inspect_managed_artifact, inspect_managed_members, inspect_managed_native_boundaries and the managed comparison operations report unsupported metadata or signature forms as an AnalysisTargetFailureError (failure_kind unsupported, format pe-cli, field, offset) instead of a bare unsupported target. inspect_il2cpp_metadata reports a binary/metadata pair that does not link as code input_conflict with failure_kind conflict and details.inputs, instead of invalid_request with details.issues, and metadata version 108 with failure_kind unsupported. * 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(il2cpp): describe pair conflicts as input_conflict with both inputs * 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 * 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 * 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 * 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 --------- Co-authored-by: Cursor Agent Co-authored-by: morluto --- docs/il2cpp-metadata.md | 11 ++- src/cli/projectCliAnalysisResult.ts | 32 +++++++- .../managed/managedReaderFailure.test.ts | 19 +++-- src/domain/managed/managedReaderFailure.ts | 75 +++++++++++-------- src/il2cpp/Il2cppMetadataProvider.ts | 48 ++++++------ tests/acceptance/il2cppMetadataCli.test.ts | 24 ++---- .../il2cpp/il2cppMetadataProvider.test.ts | 36 ++++----- 7 files changed, 140 insertions(+), 105 deletions(-) diff --git a/docs/il2cpp-metadata.md b/docs/il2cpp-metadata.md index 1210ee1914..e21224b5c3 100644 --- a/docs/il2cpp-metadata.md +++ b/docs/il2cpp-metadata.md @@ -489,10 +489,13 @@ Each category says which selected file is at fault: table entry, is reported the same way with `details.format` `macho`. - **conflict**: both files parsed but do not agree. They may come from different builds, either file may be damaged, or the binary's registration - layout may be outside coverage; nothing establishes which. The refusal is an - `invalid_request` with an `invalid_value` issue for each of `path` and - `binary_path` (`--binary` in the CLI) and no `inspect_input_contract` - recovery. Neither file is called malformed. + layout may be outside coverage; nothing establishes which. The refusal has + code `input_conflict`, `details.failure_kind` `conflict`, `retry` + `after_change` and no `recovery`. `details.inputs` lists both files as + `{ field, path }`: `path` for the metadata and `binary_path` for the binary + (`binary` in the CLI, after its `--binary` option). `details.path` names + the metadata. Neither file is called malformed; select a pair from the same + build. See [target failures](reference/target-failures.md). A token that is not a MethodDef row, or a row reused within one image, is the metadata's own fault, so linking refuses it as malformed metadata with diff --git a/src/cli/projectCliAnalysisResult.ts b/src/cli/projectCliAnalysisResult.ts index 7126e29948..01867a5e62 100644 --- a/src/cli/projectCliAnalysisResult.ts +++ b/src/cli/projectCliAnalysisResult.ts @@ -80,19 +80,26 @@ export const projectCliInputFields = ( ? [{ name: binding.operation, flags: binding.flags }] : orderedOperations(binding.operations, error.details.operation); const issues = renamedIssues(error, error.details, binding); + const inputs = renamedTargetInputs(error.details, binding); const limit = flaggedLimit(error.details.limit, operations); const relatedFlags = binding.operations === undefined && error.details.operation !== binding.operation ? undefined : relatedCliFlagsFromOperations(error.details, operations); - if (issues === undefined && limit === undefined && relatedFlags === undefined) + if ( + issues === undefined && + inputs === undefined && + limit === undefined && + relatedFlags === undefined + ) return output; return { ...error, details: { ...error.details, ...(issues === undefined ? {} : { issues }), + ...(inputs === undefined ? {} : { inputs }), ...(limit === undefined ? {} : { limit }), ...(relatedFlags === undefined ? {} @@ -260,6 +267,29 @@ const renamedIssues = ( return changed ? issues : undefined; }; +/** + * A target conflict's inputs, each named by the request field that selected + * it, take this command's CLI spelling of that field. + */ +const renamedTargetInputs = ( + details: Record, + binding: CliInputFieldBinding, +): JsonValue[] | undefined => { + if (details.operation !== binding.operation || !Array.isArray(details.inputs)) + return undefined; + let changed = false; + const inputs = details.inputs.map((input) => { + if (!isObject(input) || typeof input.field !== "string") return input; + const alias = Object.hasOwn(binding.fields, input.field) + ? binding.fields[input.field] + : undefined; + if (alias === undefined || alias === input.field) return input; + changed = true; + return { ...input, field: alias }; + }); + return changed ? inputs : undefined; +}; + /** * The request parameter a limit names, when a caller selects it per call: a * parameter control, or a registered setting a request argument can also diff --git a/src/domain/managed/managedReaderFailure.test.ts b/src/domain/managed/managedReaderFailure.test.ts index ba5ded54d6..8033f80089 100644 --- a/src/domain/managed/managedReaderFailure.test.ts +++ b/src/domain/managed/managedReaderFailure.test.ts @@ -1,9 +1,6 @@ import { describe, expect, it } from "vitest"; -import { - AnalysisTargetFailureError, - AnalysisUnsupportedTargetError, -} from "../analysisErrorCore.js"; +import { AnalysisTargetFailureError } from "../analysisErrorCore.js"; import { projectAnalysisError } from "../analysisErrorProjection.js"; import type { ManagedParseIssue } from "./managedArtifact.js"; import { @@ -65,8 +62,16 @@ describe("managedInspectionTargetFailure", () => { PATH, managedFailure(code, "metadata.tables", "a newer layout"), ); - expect(failure).toBeInstanceOf(AnalysisUnsupportedTargetError); - expect(failure).toMatchObject({ path: PATH, reason: "a newer layout" }); + expect(failure).toBeInstanceOf(AnalysisTargetFailureError); + expect(failure).toMatchObject({ + path: PATH, + failure: { + kind: "unsupported", + format: "pe-cli", + field: "metadata.tables", + detail: "a newer layout", + }, + }); }, ); @@ -88,7 +93,7 @@ describe("managedInspectionTargetFailure", () => { managedFailure(code, "metadata.tables", "detail"), ); // Only a broken rule is malformed in both the inventory and a refusal. - expect(refusal instanceof AnalysisTargetFailureError).toBe( + expect(refusal?.failure.kind === "malformed").toBe( status === "malformed", ); }, diff --git a/src/domain/managed/managedReaderFailure.ts b/src/domain/managed/managedReaderFailure.ts index 4237d7ead0..60ee6197b9 100644 --- a/src/domain/managed/managedReaderFailure.ts +++ b/src/domain/managed/managedReaderFailure.ts @@ -1,7 +1,5 @@ -import { - AnalysisTargetFailureError, - AnalysisUnsupportedTargetError, -} from "../analysisErrorCore.js"; +import { AnalysisTargetFailureError } from "../analysisErrorCore.js"; +import type { TargetFailureOf } from "../targetFailure.js"; import type { ManagedParseIssue } from "./managedArtifact.js"; /** Header facts admitted before an unsupported table layout was identified. */ @@ -36,20 +34,47 @@ export class ManagedHeapAmbiguityFailure extends ManagedReaderFailure {} export const isManagedCoverageGap = (code: ManagedParseIssue["code"]) => code === "unsupported-metadata" || code === "unsupported-signature"; +/** The ParseFailure format of a managed PE/CLI image and its ECMA-335 metadata. */ +export const MANAGED_PE_CLI_FORMAT = "pe-cli"; + /** - * Metadata status after a reader stopped. A budget or a construct outside - * coverage leaves metadata unknown (`partial`); only a broken rule makes it - * `malformed`. + * The target failure a managed reader's issue establishes: the one place + * that interprets an issue code. A construct outside decoder coverage is + * `unsupported`, so a newer valid file is never called corrupt; every other + * code except `resource-limit` names a rule the bytes broke. A resource limit + * names a budget only its producer knows, so it returns `undefined`. + */ +export const managedIssueTargetFailure = ({ + code, + scope, + offset, + detail, +}: ManagedParseIssue): + | TargetFailureOf<"malformed" | "unsupported"> + | undefined => { + if (code === "resource-limit") return undefined; + const facts = { + format: MANAGED_PE_CLI_FORMAT, + detail, + field: scope, + ...(offset === null ? {} : { offset }), + }; + return isManagedCoverageGap(code) + ? { kind: "unsupported", ...facts, undecodedContent: true } + : { kind: "malformed", ...facts }; +}; + +/** + * Metadata status after a reader stopped, derived from the issue's target + * failure: only bytes that break a rule make metadata `malformed`; a budget + * or a construct outside coverage leaves it unknown (`partial`). */ export const managedMetadataFailureStatus = ( issue: ManagedParseIssue, ): "partial" | "malformed" => - issue.code === "resource-limit" || isManagedCoverageGap(issue.code) - ? "partial" - : "malformed"; - -/** The ParseFailure format of a managed PE/CLI image and its ECMA-335 metadata. */ -export const MANAGED_PE_CLI_FORMAT = "pe-cli"; + managedIssueTargetFailure(issue)?.kind === "malformed" + ? "malformed" + : "partial"; /** * The selected file's refusal when a managed reader stopped on its bytes. @@ -64,26 +89,12 @@ export const managedInspectionTargetFailure = ( operation: string, path: string, cause: unknown, -): AnalysisTargetFailureError | AnalysisUnsupportedTargetError | undefined => { +): AnalysisTargetFailureError | undefined => { if (!(cause instanceof ManagedReaderFailure)) return undefined; - const { code, scope, offset, detail } = cause.issue; - if (code === "resource-limit") return undefined; - if (isManagedCoverageGap(code)) - return new AnalysisUnsupportedTargetError(operation, path, detail, { - cause, - }); - return new AnalysisTargetFailureError( - operation, - path, - { - kind: "malformed", - format: MANAGED_PE_CLI_FORMAT, - detail, - field: scope, - ...(offset === null ? {} : { offset }), - }, - { cause }, - ); + const failure = managedIssueTargetFailure(cause.issue); + return failure === undefined + ? undefined + : new AnalysisTargetFailureError(operation, path, failure, { cause }); }; /** Construct a typed managed parse failure at an exact byte location. */ diff --git a/src/il2cpp/Il2cppMetadataProvider.ts b/src/il2cpp/Il2cppMetadataProvider.ts index ff723f445a..8f26d9436d 100644 --- a/src/il2cpp/Il2cppMetadataProvider.ts +++ b/src/il2cpp/Il2cppMetadataProvider.ts @@ -10,7 +10,10 @@ import { parseFailureAnalysisError, parseLimitConstraint, } from "../domain/parseFailureAnalysisError.js"; -import { Il2cppMetadataFormatFailure } from "./Il2cppMetadataFormat.js"; +import { + IL2CPP_METADATA_FORMAT, + Il2cppMetadataFormatFailure, +} from "./Il2cppMetadataFormat.js"; import { inspectIl2cppMetadataV108 } from "./Il2cppMetadataV108.js"; import type { AnalysisPartialObservation } from "../domain/analysisErrorBase.js"; import { jsonValueSchema } from "../domain/jsonValue.js"; @@ -42,10 +45,9 @@ import { import { jsonValueByteLength } from "../domain/jsonValueByteLength.js"; import { AnalysisCapabilityUnavailableError, - AnalysisInputError, + AnalysisTargetFailureError, AnalysisOutputError, AnalysisResourceConstraintError, - AnalysisUnsupportedTargetError, cancelledBy, } from "../domain/analysisErrorCore.js"; import { @@ -89,27 +91,20 @@ const linkConflict = ( binaryPath: string, metadataPath: string, cause: Il2cppBinaryFormatFailure, -): AnalysisInputError => - new AnalysisInputError( +): AnalysisTargetFailureError => + new AnalysisTargetFailureError( OPERATION, + metadataPath, { - cause, - conformsToInputContract: true, - remediationAction: - "Select the native binary and global-metadata.dat from the same build. If they are from the same build, either file may be damaged or the binary's registration layout may be outside coverage. Without the binary, the metadata alone can still be read.", + kind: "conflict", + format: IL2CPP_BINARY_FORMAT, + detail: `Selected metadata does not link to the selected binary: ${cause.message}`, + inputs: [ + { field: "path", path: metadataPath }, + { field: "binary_path", path: binaryPath }, + ], }, - [ - { - path: ["path"], - reason: "invalid_value", - message: `Selected metadata ${metadataPath} does not link to the selected binary: ${cause.message}`, - }, - { - path: ["binary_path"], - reason: "invalid_value", - message: `Selected binary ${binaryPath} does not link to the metadata: ${cause.message}`, - }, - ], + { cause }, ); const failureForPrimary = ( @@ -522,10 +517,17 @@ export class Il2cppMetadataProvider implements Il2cppMetadataPort { ); assertArtifactReadActive(options?.signal); if (v108 !== null) { - const failure = new AnalysisUnsupportedTargetError( + const failure = new AnalysisTargetFailureError( OPERATION, input.path, - "unsupported-version: metadata version 108 has a partial header and string observation; type, method and binary layouts are not decoded", + { + kind: "unsupported", + format: IL2CPP_METADATA_FORMAT, + detail: + "unsupported-version: metadata version 108 has a partial header and string observation; type, method and binary layouts are not decoded", + field: "version", + undecodedContent: true, + }, ); failure.partialObservation = metadataSourceEvidence( artifact, diff --git a/tests/acceptance/il2cppMetadataCli.test.ts b/tests/acceptance/il2cppMetadataCli.test.ts index 9a368d81f4..cb0152c6a5 100644 --- a/tests/acceptance/il2cppMetadataCli.test.ts +++ b/tests/acceptance/il2cppMetadataCli.test.ts @@ -1104,23 +1104,15 @@ cliTest( const pairConflict = (reason: string) => (path: string, binaryPath: string, binaryField: string) => ({ - code: "invalid_request", + code: "input_conflict", details: { - issues: [ - { - path: ["path"], - reason: "invalid_value", - message: expect.stringContaining( - `Selected metadata ${path} does not link to the selected binary: ${reason}:`, - ), - }, - { - path: [binaryField], - reason: "invalid_value", - message: expect.stringContaining( - `Selected binary ${binaryPath} does not link to the metadata: ${reason}:`, - ), - }, + failure_kind: "conflict", + path, + reason: expect.stringContaining(`${reason}:`), + // Both inputs, each by this adapter's spelling of its field. + inputs: [ + { field: "path", path }, + { field: binaryField, path: binaryPath }, ], }, }); diff --git a/tests/boundary/il2cpp/il2cppMetadataProvider.test.ts b/tests/boundary/il2cpp/il2cppMetadataProvider.test.ts index a1bf904550..00a10c06e8 100644 --- a/tests/boundary/il2cpp/il2cppMetadataProvider.test.ts +++ b/tests/boundary/il2cpp/il2cppMetadataProvider.test.ts @@ -144,7 +144,10 @@ it("accepts padding after the assumed v108 header", async () => { const result = await inspectMetadata(path); expect(result.ok).toBe(false); if (result.ok) return; - expect(result.error).toBeInstanceOf(AnalysisUnsupportedTargetError); + expect(result.error).toMatchObject({ + _tag: "AnalysisTargetFailureError", + failure: { kind: "unsupported", format: "il2cpp-metadata" }, + }); expect(result.error.partialObservation).toMatchObject({ normalized_result: { version_108_partial_inventory: { @@ -970,32 +973,21 @@ it("retains both observed file identities and the selected architecture when nat if (result.ok) throw new Error("Unresolved registration accepted"); // Both files parse; neither is called malformed. The conflict lists each // selecting field and keeps each file's identity. - expect(result.error).toMatchObject({ - _tag: "AnalysisInputError", - conformsToInputContract: true, - issues: [ - { - path: ["path"], - reason: "invalid_value", - message: expect.stringContaining( - `Selected metadata ${path} does not link to the selected binary: code-registration-not-found:`, - ), - }, - { - path: ["binary_path"], - reason: "invalid_value", - message: expect.stringContaining( - `Selected binary ${binary_path} does not link to the metadata: code-registration-not-found:`, - ), - }, - ], - }); expect(projectAnalysisError(result.error)).toMatchObject({ - code: "invalid_request", + code: "input_conflict", retryable: false, remediation: { action: expect.stringContaining("from the same build"), }, + details: { + failure_kind: "conflict", + path, + reason: expect.stringContaining("code-registration-not-found:"), + inputs: [ + { field: "path", path }, + { field: "binary_path", path: binary_path }, + ], + }, }); expect(projectAnalysisError(result.error)).not.toHaveProperty("recovery"); expect(result.error.partialObservation).toMatchObject({