Corpus errors
Common error signatures
Corpus errors typically fall into three categories: duplicate alias declarations, missing or unreadable markdown files on disk, and failed lookups against a corpus that didn't load correctly.
DuplicateAliasError— raised during corpus indexing when two templates declare the same alias. The exception carriesalias,first_path, andsecond_path, so you can immediately identify which two files conflict.KeyError/Nonereturn fromget(path)—CorpusProtocol.get()returnsNonewhen the requested path doesn't exist in the index. Callers that don't handleNonewill raise aTypeErrororAttributeErrordownstream.OSError/FileNotFoundError— raised byDirectoryCorpuswhenrootdoesn't exist or a matched markdown file can't be read. Also occurs whensummaries_fileorcross_links_filepaths are invalid.ValueError— can surface duringRetrievalEntryconstruction if required fields (path,category,content) are missing or of the wrong type.
Where errors originate
Each corpus implementation has distinct failure modes. Match the exception to the class before walking the call stack further.
DirectoryCorpus(src/attune_rag/corpus/directory.py) — errors here are almost always filesystem or indexing problems:rootdoesn't exist, theglobpattern (**/*.mdby default) matches no files, or two templates share an alias. Checkpath_indexandalias_indexafter construction to verify what was loaded.AttuneHelpCorpus(src/attune_rag/corpus/attune_help.py) — wraps aHelpCorpusAdapter; errors here usually mean the bundled templates weren't packaged correctly orfrom_attune_help()couldn't locate the adapter.RetrievalEntry(src/attune_rag/corpus/base.py) — a dataclass; construction errors indicate that a markdown file's parsed metadata is missing required fields or contains unexpected types.DuplicateAliasError(src/attune_rag/corpus/base.py) — always raised during index-build time, not at query time. Thealias,first_path, andsecond_pathattributes identify the conflict precisely.
How to diagnose
-
Read
DuplicateAliasErrorattributes directly. If you see this exception, inspecterror.alias,error.first_path, anderror.second_path. Open both files and remove or rename the duplicate alias declaration in one of them. -
Verify the corpus loaded entries. After constructing a
DirectoryCorpus, calllen(list(corpus.entries()))and inspectcorpus.path_index. An empty index means therootpath is wrong or the glob matched nothing — confirmrootexists and contains*.mdfiles. -
Check
get()return values before attribute access.CorpusProtocol.get(path)returnsNonefor an unknown path. If you're seeingAttributeError: 'NoneType' object has no attribute '...', add aNonecheck or log the path value to confirm it matches the keys inpath_index. -
Inspect the
versionfingerprint for caching issues.DirectoryCorpus.versionis a SHA-256 fingerprint of the loaded corpus. If you suspect stale data whencache=True, compare theversionvalue before and after the file change to confirm the corpus was actually reloaded. -
Isolate
AttuneHelpCorpusadapter failures. Iffrom_attune_help()raises, the bundledHelpCorpusAdaptermay be missing from your installation. Verify the package was installed with its data files intact and thatAttuneHelpCorpus.nameandAttuneHelpCorpus.versionreturn non-empty strings before makingentries()orget()calls.
Source files
src/attune_rag/corpus/__init__.pysrc/attune_rag/corpus/base.pysrc/attune_rag/corpus/directory.pysrc/attune_rag/corpus/attune_help.py
Tags: corpus, loader, markdown, attune-help