{"record":{"id":"9f7479a390209500","repo":"weaviate/weaviate","slug":"near-object-id-is-required","errorCode":null,"errorMessage":"near_object: id is required","messagePattern":"near_object: id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/handlers/grpc/v1/parse_aggregate_request.go","lineNumber":131,"sourceCode":"\t\t\t// also part of the GraphQL API, so we need to duplicate it in order to get\n\t\t\t// the same behavior\n\t\t\tif nv.Distance != nil && nv.Certainty != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"near_vector: cannot provide distance and certainty\")\n\t\t\t}\n\n\t\t\tif nv.Certainty != nil {\n\t\t\t\tparams.NearVector.Certainty = *nv.Certainty\n\t\t\t}\n\n\t\t\tif nv.Distance != nil {\n\t\t\t\tparams.NearVector.Distance = *nv.Distance\n\t\t\t\tparams.NearVector.WithDistance = true\n\t\t\t}\n\t\t}\n\tcase *pb.AggregateRequest_NearObject:\n\t\tif no := search.NearObject; no != nil {\n\t\t\tif no.Id == \"\" {\n\t\t\t\treturn nil, fmt.Errorf(\"near_object: id is required\")\n\t\t\t}\n\t\t\tparams.NearObject = &searchparams.NearObject{\n\t\t\t\tID:            no.Id,\n\t\t\t\tTargetVectors: targetVectors,\n\t\t\t}\n\n\t\t\t// The following business logic should not sit in the API. However, it is\n\t\t\t// also part of the GraphQL API, so we need to duplicate it in order to get\n\t\t\t// the same behavior\n\t\t\tif no.Distance != nil && no.Certainty != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"near_object: cannot provide distance and certainty\")\n\t\t\t}\n\n\t\t\tif no.Certainty != nil {\n\t\t\t\tparams.NearObject.Certainty = *no.Certainty\n\t\t\t}\n\n\t\t\tif no.Distance != nil {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/handlers/grpc/v1/parse_aggregate_request.go#L113-L149","documentation":"The gRPC Aggregate request contained a near_object search clause without an object id. Weaviate requires the id to resolve the object's vector before performing the near-object aggregation, so the parse layer rejects the request before any search runs. This mirrors the same validation in the GraphQL API layer.","triggerScenarios":"Sending a pb.AggregateRequest with Search set to NearObject whose Id field is the empty string (field left unset in the client or proto zero value).","commonSituations":"Client code builds the NearObject message but forgets to assign Id (e.g. passing a struct with a nil/empty id because the lookup failed upstream, or a dynamic id variable that was empty).","solutions":["Set the Id field on the NearObject message before sending the Aggregate request.","In the client, fail fast when the source object id is missing instead of sending the request.","If you only need vector-similarity, switch to near_vector with an explicit vector."],"exampleFix":"// before\nsearch := &pb.AggregateRequest_NearObject{NearObject: &pb.NearObject{}}\n// after\nsearch := &pb.AggregateRequest_NearObject{NearObject: &pb.NearObject{Id: \"some-uuid\"}}","handlingStrategy":"validation","validationCode":"if req.GetNearObject() != nil && req.GetNearObject().GetId() == \"\" {\n    return errors.New(\"near_object: id is required\")\n}","typeGuard":"func hasValidNearObjectId(no *pb.NearObject) bool {\n    return no != nil && no.Id != \"\"\n}","tryCatchPattern":null,"preventionTips":["Always populate NearObject.Id from a verified source record.","Validate the id is a non-empty UUID in the client request builder."],"tags":["grpc","validation","aggregate","near-object"],"backgroundTag":"missing-required-argument","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"}