{"record":{"id":"cbbc230870fb652c","repo":"weaviate/weaviate","slug":"set-secondary-index-d-on-an-index-of-length-d","errorCode":null,"errorMessage":"set secondary index %d on an index of length %d","messagePattern":"set secondary index (.+?) on an index of length (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/lsmkv/bucket_options.go","lineNumber":201,"sourceCode":"\t\treturn nil\n\t}\n}\n\nfunc WithWriteSegmentInfoIntoFileName(writeSegmentInfoIntoFileName bool) BucketOption {\n\treturn func(b *Bucket) error {\n\t\tb.writeSegmentInfoIntoFileName = writeSegmentInfoIntoFileName\n\t\treturn nil\n\t}\n}\n\ntype secondaryIndexKeys [][]byte\n\ntype SecondaryKeyOption func(s secondaryIndexKeys) error\n\nfunc WithSecondaryKey(pos int, key []byte) SecondaryKeyOption {\n\treturn func(s secondaryIndexKeys) error {\n\t\tif pos > len(s) {\n\t\t\treturn errors.Errorf(\"set secondary index %d on an index of length %d\",\n\t\t\t\tpos, len(s))\n\t\t}\n\n\t\ts[pos] = key\n\n\t\treturn nil\n\t}\n}\n\nfunc WithMonitorCount() BucketOption {\n\treturn func(b *Bucket) error {\n\t\tif b.strategy != StrategyReplace {\n\t\t\treturn errors.Errorf(\"count monitoring only supported on 'replace' buckets\")\n\t\t}\n\t\tb.monitorCount = true\n\t\treturn nil\n\t}\n}","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/lsmkv/bucket_options.go#L183-L219","documentation":"WithSecondaryKey is a guard-style validation option: it rejects any write attempt that supplies a secondary key at a position beyond the configured secondary-index capacity of the bucket. The caller passed pos greater than the number of allocated secondary index slots, which would corrupt the segment layout.","triggerScenarios":"Thrown at adapters/repos/db/lsmkv/bucket_options.go:201 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the caller to only use positions 0..secondaryIndexCount-1 when inserting","Ensure the bucket is created with enough secondary indices for the keys being written"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}