From 630ce39c220228209b9feb48afaf2bcd0da731ce Mon Sep 17 00:00:00 2001 From: gensokyo-dev Date: Tue, 1 Dec 2026 16:27:12 +0000 Subject: [PATCH] fix(target): name the raw-binary load when no route recognizes a header When header detection admitted no route for a file, open_binary and inspect_artifact refused it with the generic "select a supported, well-formed target", leaving no next step for a headerless firmware or memory image. The explicit raw-binary load is the only route that admits such a file, so the producer now names it with its required architecture and entry_point. inspect_artifact shares the same detection, so it is not offered as a way to identify the file. Refs #15319 Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> --- src/application/BinaryTargetResolver.ts | 4 ++++ tests/boundary/cli/rawBinaryCli.test.ts | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/application/BinaryTargetResolver.ts b/src/application/BinaryTargetResolver.ts index 216924b688f..fa9ea051fec 100644 --- a/src/application/BinaryTargetResolver.ts +++ b/src/application/BinaryTargetResolver.ts @@ -567,6 +567,10 @@ const readOpenedBinaryTarget = async ( new BinaryTargetError(path, reason, { constraint: "file_format_rejected", ...(diagnostics === undefined ? {} : { diagnostics }), + // inspect_artifact shares this detection, so only the explicit + // raw-binary load admits a file whose header no route recognizes. + remediationAction: + 'Select a supported, well-formed target. To analyze a headerless firmware or memory image, open it with format "raw-binary", architecture and entry_point.', }), ); } diff --git a/tests/boundary/cli/rawBinaryCli.test.ts b/tests/boundary/cli/rawBinaryCli.test.ts index 500598237c1..33787b2a3bd 100644 --- a/tests/boundary/cli/rawBinaryCli.test.ts +++ b/tests/boundary/cli/rawBinaryCli.test.ts @@ -72,8 +72,14 @@ cliTest( XDG_CACHE_HOME: root, }, }); + // Detection never assumes raw-binary; the refusal names the explicit load. expect(before.exitCode).not.toBe(0); - expect(JSON.stringify(before.json)).not.toContain("raw-binary"); + expect(before.json).toMatchObject({ + details: { constraint: "file_format_rejected" }, + remediation: { + action: expect.stringContaining('format "raw-binary", architecture'), + }, + }); const missing = await cli.run({ arguments: ["inspect", path, "--target-format", "raw-binary", "--json"], environment: {