{"record":{"id":"70ef8df2d5326b99","repo":"QL-Win/QuickLook","slug":"ds-store-unknown-record-type-stype","errorCode":null,"errorMessage":"DS_Store: unknown record type '{stype}'","messagePattern":"DS_Store: unknown record type '(.+?)'","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/DSStore/DSStoreExtractor.cs","lineNumber":245,"sourceCode":"\n        public string ReadFileName()\n        {\n            uint   length = ReadUint32();\n            byte[] buf    = ReadBuf((int)(2 * length));\n\n            // skip sid (4 bytes) and read type tag (4 bytes)\n            Skip(4);\n            byte[] stypeBytes = ReadBuf(4);\n            string stype      = Encoding.ASCII.GetString(stypeBytes);\n\n            int bytesToSkip = stype switch\n            {\n                \"bool\"           => 1,\n                \"type\" or \"long\" or \"shor\" => 4,\n                \"comp\" or \"dutc\" => 8,\n                \"blob\"           => (int)ReadUint32(),\n                \"ustr\"           => (int)(2 * ReadUint32()),\n                _                => throw new InvalidDataException($\"DS_Store: unknown record type '{stype}'\")\n            };\n\n            Skip((uint)bytesToSkip);\n\n            // filename is encoded as UTF-16 big-endian\n            return Encoding.BigEndianUnicode.GetString(buf);\n        }\n    }\n}\n","sourceCodeStart":227,"sourceCodeEnd":255,"githubUrl":"https://github.com/QL-Win/QuickLook/blob/cb5d9c429c81d9796fac469da2a68efb5626946d/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/DSStore/DSStoreExtractor.cs#L227-L255","documentation":"Thrown while parsing a macOS .DS_Store file: after skipping a 4-byte sid and reading a 4-byte ASCII type tag, the tag did not match any of the known record types (bool, type, long, shor, comp, dutc, blob, ustr). This is an InvalidDataException signalling that the parser encountered a structure it cannot decode. The QuickLook ArchiveViewer uses this to bail out on a malformed or unsupported .DS_Store embedded inside a ZIP/archive.","triggerScenarios":"ReadBuf(4) returns 4 bytes whose ASCII decoding is not one of {bool, type, long, shor, comp, dutc, blob, ustr}; the switch expression falls to its '_' arm. Happens when the .DS_Store stream is truncated, byte-shifted, or produced by a macOS version that emits a record type this parser does not know.","commonSituations":"Corrupted download of a macOS archive; a .DS_Store rewritten by a newer macOS release that introduced a new value type; a file that merely has a .DS_Store name but is not actually a Finder .DS_Store; partial extraction leaving the record header incomplete.","solutions":["Confirm the file is a genuine .DS_Store (magic 'Bud1\\0' at offset 0) before invoking the extractor.","If you control the parser, map the new tag to its documented size instead of throwing, or extend the switch with the missing case.","Wrap the extraction in a try/catch for InvalidDataException and fall back to skipping the .DS_Store entry when previewing an archive.","Re-download or re-create the archive if the .DS_Store is byte-corrupted."],"exampleFix":"// before\n_ => throw new InvalidDataException($\"DS_Store: unknown record type '{stype}'\")\n\n// after: tolerate unknown tags by reading a length-prefixed value when present\n_ => (int)ReadUint32()","handlingStrategy":"validation","validationCode":"// verify .DS_Store magic 'Bud1\\0' (0x42756431 then 0x0000) before parsing\nusing var fs = File.OpenRead(path);\nSpan<byte> magic = stackalloc byte[8];\nif (await fs.ReadAsync(magic) < 8) return false;\nreturn magic[0]=='B' && magic[1]=='u' && magic[2]=='d' && magic[3]=='1' && magic[4]==0 && magic[5]==0;","typeGuard":"static bool IsLikelyDsStore(byte[] head) => head.Length >= 8 && head[0]=='B' && head[1]=='u' && head[2]=='d' && head[3]=='1';","tryCatchPattern":"try { DSStoreExtractor.Extract(stream); }\ncatch (InvalidDataException) { /* skip this .DS_Store entry, continue archive preview */ }","preventionTips":["Only feed the extractor files that pass the 'Bud1' magic check.","Treat .DS_Store parse failures as non-fatal when previewing archives.","Extend the type-tag switch when adopting newer macOS .DS_Store formats."],"tags":["ds-store","macos","binary-parsing","archive"],"backgroundTag":null,"analyzedSha":"cb5d9c429c81d9796fac469da2a68efb5626946d","analyzedAt":"2026-08-13T11:51:01.370Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}