{"record":{"id":"dd5bb46adeded6c5","repo":"weaviate/weaviate","slug":"dist-between-d-and-d","errorCode":null,"errorMessage":"dist between %d and %d","messagePattern":"dist between (.+?) and (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/vector/hnsw/neighbor_connections.go","lineNumber":366,"sourceCode":"\t\t// we can simply append\n\t\t// updatedConnections = append(currentConnections, n.node.id)\n\t\tneighbor.appendConnectionAtLevelNoLock(level, n.node.id, maximumConnections)\n\t\tif err := n.graph.commitLog.AddLinkAtLevel(neighbor.id, level, n.node.id); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\t// we need to run the heuristic\n\n\t\tdist, err := n.graph.distBetweenNodes(n.node.id, neighborID)\n\t\tif err != nil {\n\t\t\tvar e storobj.ErrNotFound\n\t\t\tif errors.As(err, &e) {\n\t\t\t\tn.graph.handleDeletedNode(e.DocID, \"connectNeighborAtLevel\")\n\t\t\t\t// it seems either the node or the neighbor were deleted in the meantime,\n\t\t\t\t// there is nothing we can do now\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn errors.Wrapf(err, \"dist between %d and %d\", n.node.id, neighborID)\n\t\t}\n\n\t\tcandidates := priorityqueue.NewMax[any](len(currentConnections) + 1)\n\t\tcandidates.Insert(n.node.id, dist)\n\n\t\tfor _, existingConnection := range currentConnections {\n\t\t\tdist, err := n.graph.distBetweenNodes(existingConnection, neighborID)\n\t\t\tif err != nil {\n\t\t\t\tvar e storobj.ErrNotFound\n\t\t\t\tif errors.As(err, &e) {\n\t\t\t\t\tn.graph.handleDeletedNode(e.DocID, \"connectNeighborAtLevel\")\n\t\t\t\t\t// was deleted in the meantime\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\treturn errors.Wrapf(err, \"dist between %d and %d\", existingConnection, neighborID)\n\t\t\t}\n\n\t\t\tcandidates.Insert(existingConnection, dist)","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/vector/hnsw/neighbor_connections.go#L348-L384","documentation":"Wraps a distance-calculation error between the inserted node and one of its neighbors inside connectNeighborAtLevel. Deleted objects (storobj.ErrNotFound) are handled gracefully; any other distancer error is wrapped here and aborts neighbor connection for that node.","triggerScenarios":"connectNeighborAtLevel calls the distancer for (node, neighborID) and gets a non-ErrNotFound error — e.g. the neighbor object exists but its vector is unreadable/corrupt, or a quantization/PQ codec errors on the stored bytes.","commonSituations":"Corrupted or truncated vector data after an unclean shutdown; wrong distance metric configured for imported vectors (NaN/Inf vectors); module-serialized vectors failing to deserialize.","solutions":["Identify the object IDs from the wrapped error and validate/repair their vectors (re-export and re-import the affected objects)","Check for NaN/Inf values in vectors supplied at import time and fix client-side normalization","Restore the shard from backup if vectors on disk are corrupt","Keep weaviate upgraded — several distancer error-handling fixes landed in later versions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate vectors client-side before batch import\nfor _, o := range objects {\n  if len(o.Vector) != expectedDim { return fmt.Errorf(\"dim mismatch for %s\", o.ID) }\n  for _, x := range o.Vector { if math.IsNaN(float64(x)) || math.IsInf(float64(x), 0) { return fmt.Errorf(\"non-finite vector for %s\", o.ID) } }\n}","typeGuard":"func validVector(v []float32, dim int) bool {\n  if len(v) != dim { return false }\n  for _, x := range v { if math.IsNaN(float64(x)) || math.IsInf(float64(x), 0) { return false } }\n  return true\n}","tryCatchPattern":null,"preventionTips":["Validate vector dimensionality and finiteness before import","Match the configured vectorizer/distance metric to the data","Back up shards; restore if disk-level corruption is detected","Upgrade weaviate for improved distancer error handling"],"tags":["hnsw","distance-calculation","vector-corruption"],"backgroundTag":"vector-distance-calculation-failed","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"}