gohugoio/hugo · error
index config for %q not found
Error message
index config for %q not found
What it means
Returned by InvertedIndex.searchDate as a defensive check when getIndexCfg cannot find the IndexConfig for a query element's index name. Because searchDate is only called after Search resolves configs, reaching this branch indicates the config and the constructed index are out of sync -- the posting-list map has the index (527 passed) but the config slice does not.
Source
Thrown at related/inverted_index.go:479
matchm := make(map[Document]*rank, 200)
defer func() {
for _, r := range matchm {
putRank(r)
}
}()
applyDateFilter := !idx.cfg.IncludeNewer && !upperDate.IsZero()
var fragmentsFilter collections.SortedStringSlice
for _, el := range query {
setm, found := idx.index[el.Index]
if !found {
return []Document{}, fmt.Errorf("index for %q not found", el.Index)
}
config, found := idx.getIndexCfg(el.Index)
if !found {
return []Document{}, fmt.Errorf("index config for %q not found", el.Index)
}
for _, kw := range el.Keywords {
if docs, found := setm[kw]; found {
for _, doc := range docs {
if compare.Eq(doc, self) {
continue
}
if applyDateFilter {
// Exclude newer than the limit given
if doc.PublishDate().After(upperDate) {
continue
}
}
if config.Type == TypeFragments && config.ApplyFilter {
if fkw, ok := kw.(FragmentKeyword); ok {View on GitHub (pinned to 52c9bd7908)
Solutions
- Treat the related Config as immutable after NewInvertedIndex; rebuild the index if config changes.
- Ensure NewInvertedIndex receives the fully-decoded, final Config.
- Avoid sharing a Config value between index construction and later mutation.
Example fix
// before: mutate cfg after building index cfg.Indices = append(cfg.Indices, newIndex) idx := related.NewInvertedIndex(cfg) cfg.Indices = cfg.Indices[:0] // desync! // after: build once, never mutate finalCfg := buildRelatedConfig() idx := related.NewInvertedIndex(finalCfg)
Defensive patterns
Strategy: validation
Validate before calling
// Treat Config as immutable; rebuild index on change.
func rebuildIndex(cfg related.Config) *related.InvertedIndex {
return related.NewInvertedIndex(cfg) // cfg must be final, never mutated after
} Prevention
- Never mutate related.Config after passing it to NewInvertedIndex.
- Keep idx.cfg.Indices and idx.index keys in sync by construction.
- Avoid sharing a Config pointer between builder and runtime mutators.
When it happens
Trigger: An index name exists as a key in idx.index (added at construction time) but idx.cfg.Indices no longer contains an IndexConfig with that Name -- e.g. config mutated after NewInvertedIndex, or a partial config reload.
Common situations: Runtime mutation of the related Config after the InvertedIndex was built; a custom integration that partially rebuilds config; concurrent config swap without recreating the index.
Related errors
- index for %q not found
- failed to decode related config: %w
- index %q not found
- index %q not valid
- there is no such an operation
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/0b935245b1f949b3.
Report an issue: GitHub.