{"record":{"id":"888ef1c33a46a533","repo":"weaviate/weaviate","slug":"object-inconsistent-vector-lengths-found-dimensi","errorCode":null,"errorMessage":"object: inconsistent vector lengths found: dimensions=%d and object=%d","messagePattern":"object: inconsistent vector lengths found: dimensions=(.+?) and object=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/text2vec-contextionary/additional/sempath/builder.go","lineNumber":165,"sourceCode":"\n\treturn nn[0].Neighbors, nil\n}\n\n// TODO: document behavior if it actually stays like this\nfunc (pb *PathBuilder) vectorsToMatrix(obj search.Result, allObjects []search.Result, dims int,\n\tparams *Params, searchNeighbors []*txt2vecmodels.NearestNeighbor,\n) (*mat.Dense, []*txt2vecmodels.NearestNeighbor, error) {\n\titems := 1 // the initial object\n\tvar neighbors []*txt2vecmodels.NearestNeighbor\n\tneighbors = pb.extractNeighbors(allObjects)\n\tneighbors = append(neighbors, searchNeighbors...)\n\tneighbors = pb.removeDuplicateNeighborsAndDollarNeighbors(neighbors)\n\titems += len(neighbors) + 1 // The +1 is for the search vector which we append last\n\n\t// concat all vectors to build gonum dense matrix\n\tmergedVectors := make([]float64, items*dims)\n\tif l := len(obj.Vector); l != dims {\n\t\treturn nil, nil, fmt.Errorf(\"object: inconsistent vector lengths found: dimensions=%d and object=%d\", dims, l)\n\t}\n\n\tfor j, dim := range obj.Vector {\n\t\tmergedVectors[j] = float64(dim)\n\t}\n\n\twithoutNeighbors := 1 * dims\n\tfor i, neighbor := range neighbors {\n\t\tneighborVector := neighbor.Vector\n\n\t\tif l := len(neighborVector); l != dims {\n\t\t\treturn nil, nil, fmt.Errorf(\"neighbor: inconsistent vector lengths found: dimensions=%d and object=%d\", dims, l)\n\t\t}\n\n\t\tfor j, dim := range neighborVector {\n\t\t\tmergedVectors[withoutNeighbors+i*dims+j] = float64(dim)\n\t\t}\n\t}","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/modules/text2vec-contextionary/additional/sempath/builder.go#L147-L183","documentation":"vectorsToMatrix flattens the object vector and its neighbors' vectors into one dense matrix of width dims. Before copying, it checks the object's vector length equals the expected dims derived from params; otherwise the flattened buffer would be misaligned. The error reports both lengths.","triggerScenarios":"semanticPath computation where the search result's object vector length differs from params.Dims (or similar) — e.g. the collection was re-vectorized with a different model producing different dimensions than the params/neighbor vectors assume.","commonSituations":"Mixed-dimension vectors in one collection after changing vectorizer settings; legacy objects from an older contextionary version alongside new ones.","solutions":["Re-vectorize the object so its dimensions match params.Dims","Ensure all objects in the collection use the same vectorizer/model settings (fix moduleConfig)","Check where params dimensions are set for semanticPath and make them consistent with the stored vectors"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"dims := len(params.Vector)\nif len(obj.Vector) != dims {\n  return fmt.Errorf(\"object vector dim %d != expected %d; re-vectorize\", len(obj.Vector), dims)\n}","typeGuard":"func hasDims(v []float32, dims int) bool { return len(v) == dims }","tryCatchPattern":null,"preventionTips":["Never change vectorizer/model settings without re-vectorizing the whole collection","Check all stored vector lengths are equal after migrations","Use one dimensionality per collection"],"tags":["go","vectorizer","dimensions","additional-properties"],"backgroundTag":"dimension-mismatch","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"}