{"record":{"id":"a683ce16964fcdad","repo":"kopia/kopia","slug":"pack-offset-v-is-too-high","errorCode":null,"errorMessage":"pack offset %v is too high","messagePattern":"pack offset (.+?) is too high","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"repo/content/index/index_v2.go","lineNumber":470,"sourceCode":"\tif len(packID2Index) > v2MaxShortPackIDCount {\n\t\tentrySize = max(entrySize, v2EntryOffsetExtendedPackBlobIDEnd)\n\t}\n\n\t// compute maximum content length to determine how many bits we need to use to store it.\n\tmaxPackedLen, maxOriginalLength, maxPackOffset := maxContentLengths(sortedInfos)\n\n\t// contents >= 28 bits (256 MiB) can't be stored at all.\n\tif maxPackedLen >= v2MaxContentLength || maxOriginalLength >= v2MaxContentLength {\n\t\treturn nil, errors.Errorf(\"maximum content length is too high: (packed %v, original %v, max %v)\", maxPackedLen, maxOriginalLength, v2MaxContentLength)\n\t}\n\n\t// contents >= 24 bits (16 MiB) requires extra 0.5 byte per length.\n\tif maxPackedLen >= v2MaxShortContentLength || maxOriginalLength >= v2MaxShortContentLength {\n\t\tentrySize = max(entrySize, v2EntryOffsetHighLengthBitsEnd)\n\t}\n\n\tif maxPackOffset >= v2MaxPackOffset {\n\t\treturn nil, errors.Errorf(\"pack offset %v is too high\", maxPackOffset)\n\t}\n\n\tkeyLength := -1\n\n\tif len(sortedInfos) > 0 {\n\t\tvar hashBuf [maxContentIDSize]byte\n\n\t\tkeyLength = len(contentIDToBytes(hashBuf[:0], sortedInfos[0].ContentID))\n\t}\n\n\treturn &indexBuilderV2{\n\t\tpackBlobIDOffsets:      map[blob.ID]uint32{},\n\t\tkeyLength:              keyLength,\n\t\tentrySize:              entrySize,\n\t\tentryCount:             len(sortedInfos),\n\t\tuniqueFormatInfo2Index: uniqueFormat2Index,\n\t\tpackID2Index:           packID2Index,\n\t}, nil","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/repo/content/index/index_v2.go#L452-L488","documentation":"The v2 index encodes each entry's pack offset in a fixed bit field capped at v2MaxPackOffset. During index building, if the largest pack offset across all contents (computed by maxContentLengths) exceeds that cap, the offset cannot be represented and building fails with this error. It indicates a single pack file is too large for the v2 entry encoding.","triggerScenarios":"Building a v2 index where maxPackOffset >= v2MaxPackOffset — i.e. some content lives at an offset inside its pack file beyond the maximum encodable offset (a very large pack, roughly at/above the 256 MiB scale).","commonSituations":"Oversized pack files produced by huge writes or unbounded compaction, then indexed into a v2 index segment.","solutions":["Split the oversized pack into smaller packs so all offsets stay below v2MaxPackOffset.","Cap pack file size in the writer/packager configuration to keep offsets within the encodable range.","Check v2MaxPackOffset in index_v2.go to confirm the exact byte threshold the offending pack exceeds.","Re-pack contents that were appended into a very large pack before rebuilding the index."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"_, _, maxOff := maxContentLengths(infos)\nif maxOff >= v2MaxPackOffset {\n    // re-pack: split the oversized pack so offsets stay under the cap\n}","typeGuard":null,"tryCatchPattern":"if err := buildIndex(infos); err != nil && strings.Contains(err.Error(), \"pack offset\") {\n    // split the offending pack file and rebuild the index\n}","preventionTips":["Cap pack file size in writer configuration.","Roll over packs before offsets approach v2MaxPackOffset.","Avoid unbounded appends into a single pack.","Check pack sizes during compaction planning."],"tags":["go","index-format","pack-offset","limit-exceeded"],"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"}