Tuesday, October 28, 2025

“LG” Spotlight Indexing Bug

Howard Oakley:

There’s a bug in Spotlight that can prevent it from indexing any of the contents of susceptible text files. This has been present since macOS 13 Ventura if not before, and is still present in Tahoe 26.0.1.

[…]

To demonstrate this bug, all you need is a single UTF-8 plain text file, created by TextEdit or any other app capable of saving plain text. Start the text with the two characters L and G, both in capitals.

[…]

This isn’t the first bug in the RichText.mdimporter. In macOS Catalina 10.15.6, the same mdimporter (then build 319.60.100) introduced a bug that broke indexing of Rich Text (RTF) files.

Drew:

The same thing happens for ‘HPA’. I suspect this might have something to do with the magic entry for Arhangel archive data (/usr/share/file/magic/archive; see also HPA archive data), or something that is trying to make an equivalent check. Notice that ‘file’ reports such a text file as being ‘Arhangel archive data’.

Like Oakley, I wouldn’t expect this to matter. Spotlight uses the file extension to determine the UTI (and therefore the importer), rather than using “magic” to look at the contents of the file. But it appears the problem is occurring after that and that the importer itself is using “magic.”

Howard Oakley:

What happens is that saving a text file starting with forbidden characters correctly triggers Spotlight’s indexing service. That identifies the file as having the UTI public.plain-text and hands it over for its contents to be indexed. But the indexer inspects those first few characters, decides it’s a different type of file altogether, and promptly returns an error 4864 for an NSCoderReadCorruptError without going any further.

[…]

It turns out that files starting with the characters Draw were characteristic of a binary vector graphics format used by the !Draw app for RISC OS 2 in 1989. Rather than believing the file’s UTI for one of the most common types of files in macOS, Spotlight’s indexer therefore decided that it was trying to import file data that must now be as rare as hens’ teeth, and wouldn’t go any further.

Previously:

5 Comments RSS · Twitter · Mastodon


I wouldn't be able to say if it's related or a similar issue, but with 10.11 (El Capitan), 10.12 (Sierra), and 10.13 (High Sierra) Spotlight would not find keywords added to RTF files. (In TextEdit, that's done using File > Show Properties.)


@NaOH My recollection is that Apple just didn’t add that feature to their RTF importer. I discovered that when first developing EagleFiler and made sure that it indexed all that metadata.


@Michael Tsai I don't doubt you because you'd know better than me. But they must have had that feature in the RTF Importer than removed it/rewritten the importer because I have RTF files with keywords from back in 10.7 Lion (2011). And Spotlight finding those files resumed with 10.14 Mojave (2018).


@NaOH It’s possible I’m recalling one of the other RTF metadata fields, not the keywords. Or maybe it’s changed multiple times, as you say.


I wonder if this sort of bug is responsible for when I type in the exact name of a file into Spotlight and it completely fails to find it? I've mostly stopped using Spotlight because it became so unreliable.

Leave a Comment