{"record":{"id":"11ef7e62a230784f","repo":"kopia/kopia","slug":"unsupported-too-many-index-v2-format-infos","errorCode":null,"errorMessage":"unsupported - too many index v2 format infos","messagePattern":"unsupported - too many index v2 format infos","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"repo/content/index/index_v2.go","lineNumber":394,"sourceCode":"func indexV2FormatInfoFromInfo(v *Info) indexV2FormatInfo {\n\treturn indexV2FormatInfo{\n\t\tformatVersion:       v.FormatVersion,\n\t\tcompressionHeaderID: v.CompressionHeaderID,\n\t\tencryptionKeyID:     v.EncryptionKeyID,\n\t}\n}\n\n// buildUniqueFormatToIndexMap builds a map of unique indexV2FormatInfo to their numeric identifiers.\nfunc buildUniqueFormatToIndexMap(sortedInfos []*Info) (map[indexV2FormatInfo]byte, error) {\n\tresult := map[indexV2FormatInfo]byte{}\n\n\tfor _, v := range sortedInfos {\n\t\tkey := indexV2FormatInfoFromInfo(v)\n\t\tif _, ok := result[key]; !ok {\n\t\t\trl := len(result)\n\n\t\t\tif rl > maxUInt8 {\n\t\t\t\treturn nil, errors.New(\"unsupported - too many index v2 format infos\")\n\t\t\t}\n\n\t\t\tresult[key] = byte(rl)\n\t\t}\n\t}\n\n\treturn result, nil\n}\n\n// buildPackIDToIndexMap builds a map of unique blob IDs to their numeric identifiers.\nfunc buildPackIDToIndexMap(sortedInfos []*Info) map[blob.ID]int {\n\tresult := map[blob.ID]int{}\n\n\tfor _, v := range sortedInfos {\n\t\tblobID := v.PackBlobID\n\t\tif _, ok := result[blobID]; !ok {\n\t\t\tresult[blobID] = len(result)\n\t\t}","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/repo/content/index/index_v2.go#L376-L412","documentation":"Index v2 assigns each distinct content-format info (compression/encryption tuple) a one-byte ID, so at most maxUInt8 (255) distinct format infos are supported. When building a v2 index with more than 255 distinct format infos, this error is returned. It is an explicit format-capacity limit, not data corruption.","triggerScenarios":"Building an index v2 where the number of distinct indexV2FormatInfo values (distinct combinations of compression header ID and encryption key ID across entries) exceeds 255 during buildV2.","commonSituations":"Repositories that historically used many different compressors/encryption keys, accumulating hundreds of distinct format combinations in content info; long-lived repos migrated across many compressor settings.","solutions":["Reduce the number of distinct compression/encryption formats (rewrite content with a single compressor/encryption scheme).","Split/reorganize content into multiple indexes so each stays under 255 format infos.","Use a newer index format version with a larger format-info capacity if available."],"exampleFix":"// before\n// one giant index built over content using 300 distinct compressor/key combos\nidx := v2Builder.Build()\n// after\n// rewrite content with a single compressor, then build\nrewriteWithCompressor(ctx, compression.HeaderZstd)\nidx := v2Builder.Build()","handlingStrategy":"validation","validationCode":"// Go: count distinct format infos before building a v2 index\nfunc tooManyFormatInfos(infos []content.Info, max uint8) bool {\n\tseen := map[indexV2FormatInfo]struct{}{}\n\tfor _, v := range infos {\n\t\tseen[indexV2FormatInfoFromInfo(v)] = struct{}{}\n\t\tif len(seen) > int(max) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}","typeGuard":null,"tryCatchPattern":"idx, err := buildV2Index(ctx, contents)\nif err != nil && strings.Contains(err.Error(), \"too many index v2 format infos\") {\n\t// split into multiple indexes or rewrite with fewer formats\n}","preventionTips":["Standardize on one compressor and one encryption scheme per repository.","Periodically rewrite old content to shed legacy format combos.","Split very large repositories into multiple index shards."],"tags":["index","format-limitation","capacity"],"backgroundTag":"value-out-of-range","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}