diff --git a/src/artifacts/apple/AppleAssetCatalogAnalysis.test.ts b/src/artifacts/apple/AppleAssetCatalogAnalysis.test.ts index ca0c036e6..eae3a410e 100644 --- a/src/artifacts/apple/AppleAssetCatalogAnalysis.test.ts +++ b/src/artifacts/apple/AppleAssetCatalogAnalysis.test.ts @@ -1,6 +1,13 @@ +import { mkdir, writeFile } from "node:fs/promises"; +import { join } from "node:path"; + import { describe, expect, it } from "vitest"; -import { collectInterfaceBuilderResourceKeys } from "./AppleAssetCatalogAnalysis.js"; +import { createTestTempDirectory } from "../../../tests/fixtures/temporaryDirectory.js"; +import { + analyzeAppleAssetCatalogs, + collectInterfaceBuilderResourceKeys, +} from "./AppleAssetCatalogAnalysis.js"; describe("Apple asset catalog application workflow", () => { it("joins only explicit resource-key fields with archive provenance", () => { @@ -40,4 +47,28 @@ describe("Apple asset catalog application workflow", () => { }, ]); }); + + it("reports an app without compiled catalogs as an empty observed inventory", async () => { + const bundle = await createTestTempDirectory("rea-asset-catalog-absent-"); + await mkdir(join(bundle, "Contents", "Resources"), { recursive: true }); + await writeFile(join(bundle, "Contents", "Resources", "icon.icns"), ""); + const result = await analyzeAppleAssetCatalogs({ + bundlePath: bundle, + targetSha256: "a".repeat(64), + runAssetUtil: () => { + throw new Error("assetutil must not run without a catalog"); + }, + }); + expect(result).toMatchObject({ + catalogs: [], + total_records: 0, + records: [], + resource_key_matches: [], + next_offset: null, + truncated: false, + }); + expect(result.limitations).toContain( + "No compiled Assets.car catalog was found in the app bundle; any resource keys are reported as unmatched.", + ); + }); }); diff --git a/src/artifacts/apple/AppleAssetCatalogAnalysis.ts b/src/artifacts/apple/AppleAssetCatalogAnalysis.ts index 36b88eb13..48833764e 100644 --- a/src/artifacts/apple/AppleAssetCatalogAnalysis.ts +++ b/src/artifacts/apple/AppleAssetCatalogAnalysis.ts @@ -69,11 +69,6 @@ export const analyzeAppleAssetCatalogs = async (input: { } finally { await reader.close(); } - if (catalogs.length === 0) - throw new ArtifactReaderFailure( - "unavailable", - "No compiled Assets.car catalogs were found in the app bundle", - ); const interfaceBuilder = await analyzeInterfaceBuilderBundle({ bundlePath: input.bundlePath, targetSha256: input.targetSha256, @@ -93,6 +88,13 @@ export const analyzeAppleAssetCatalogs = async (input: { ...result, limitations: [ ...result.limitations, + // An app without a compiled catalog is an observed empty inventory, not + // a missing host tool. + ...(catalogs.length === 0 + ? [ + "No compiled Assets.car catalog was found in the app bundle; any resource keys are reported as unmatched.", + ] + : []), "Exact resource-key joins use only recognized image or asset key fields on decoded Interface Builder resource objects; other archive resource references are not inferred.", ...(interfaceBuilder.graph.truncated ? [