From ada133c256a34128cd66fef4113525f751a551f4 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Wed, 14 Oct 2026 15:20:02 +0800 Subject: [PATCH] fix(reference): retain unknown kind for unsupported source entries Keep FIFO, socket and device entries unknown instead of projecting unsupported reader entries as ordinary files. Preserve real file read-failure identity. Fixes #3218 Co-authored-by: Saim Shafique --- .../ReferenceSourceImportEntries.test.ts | 58 +++++++++++++++++++ .../ReferenceSourceImportEntries.ts | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/src/application/ReferenceSourceImportEntries.test.ts b/src/application/ReferenceSourceImportEntries.test.ts index 387e2b70cf..e0fbf2434d 100644 --- a/src/application/ReferenceSourceImportEntries.test.ts +++ b/src/application/ReferenceSourceImportEntries.test.ts @@ -6,6 +6,64 @@ import { parseReferenceSourceEntries } from "./ReferenceSourceImportEntries.js"; import { historicalSourceLanguages } from "../domain/referenceSourceGraph.js"; import type { ReferenceSourceRead } from "../reference/ReferenceSourceReaderTypes.js"; +it("projects an unsupported non-regular entry as unknown kind instead of file", () => { + const read: ReferenceSourceRead = { + root: "/selected/source", + entries: [ + { + status: "failed", + kind: "other", + path: "src/pipe", + code: "unsupported", + message: "Entry is not a regular file", + size: 0, + }, + ], + bytesRead: 0, + limitations: [], + }; + const parsed = parseReferenceSourceEntries(read, new Set()); + expect(parsed.entries).toContainEqual({ + path: "src/pipe", + kind: "unknown", + classifications: ["unknown"], + limitations: [ + "Entry is not a regular file Exclude this entry or replace it with a regular file.", + ], + }); + expect(parsed.entries.some((entry) => entry.kind === "file")).toBe(false); +}); + +it("keeps a failed regular file as file kind", () => { + const read: ReferenceSourceRead = { + root: "/selected/source", + entries: [ + { + status: "failed", + kind: "file", + path: "src/broken.ts", + code: "io", + message: "Entry could not be read", + }, + ], + bytesRead: 0, + limitations: [], + }; + const parsed = parseReferenceSourceEntries(read, new Set()); + expect(parsed.entries).toContainEqual({ + path: "src/broken.ts", + kind: "file", + sha256: null, + size: null, + language: null, + classifications: ["source"], + content_state: "unreadable", + limitations: [ + "Entry could not be read This file could not be read. Check its permissions, then try again.", + ], + }); +}); + it("retains Kotlin source identity and language across the inventory projection", () => { const files = [ [ diff --git a/src/application/ReferenceSourceImportEntries.ts b/src/application/ReferenceSourceImportEntries.ts index 29dbef3568..d2602df044 100644 --- a/src/application/ReferenceSourceImportEntries.ts +++ b/src/application/ReferenceSourceImportEntries.ts @@ -75,7 +75,7 @@ const failedEntry = ( classifications, limitations: [limitation], }; - if (entry.kind === "unknown") + if (entry.kind === "unknown" || entry.kind === "other") return { path: entry.path, kind: "unknown",