{"record":{"id":"d1fbf39b41880170","repo":"thanos-io/thanos","slug":"no-targets","errorCode":null,"errorMessage":"no targets","messagePattern":"no targets","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/targets/targets.go","lineNumber":202,"sourceCode":"\t// This field just exist to pseudo-implement the unused methods of the interface.\n\ttargetspb.Targets_TargetsServer\n\tctx context.Context\n\n\twarnings annotations.Annotations\n\ttargets  *targetspb.TargetDiscovery\n\tmu       sync.Mutex\n}\n\nfunc (srv *targetsServer) Send(res *targetspb.TargetsResponse) error {\n\tif res.GetWarning() != \"\" {\n\t\tsrv.mu.Lock()\n\t\tdefer srv.mu.Unlock()\n\t\tsrv.warnings.Add(errors.New(res.GetWarning()))\n\t\treturn nil\n\t}\n\n\tif res.GetTargets() == nil {\n\t\treturn errors.New(\"no targets\")\n\t}\n\tsrv.mu.Lock()\n\tdefer srv.mu.Unlock()\n\tsrv.targets.ActiveTargets = append(srv.targets.ActiveTargets, res.GetTargets().ActiveTargets...)\n\tsrv.targets.DroppedTargets = append(srv.targets.DroppedTargets, res.GetTargets().DroppedTargets...)\n\n\treturn nil\n}\n\nfunc (srv *targetsServer) Context() context.Context {\n\treturn srv.ctx\n}\n","sourceCodeStart":184,"sourceCodeEnd":215,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/targets/targets.go#L184-L215","documentation":"This error is returned by the internal targetsServer.Send when a TargetsResponse arrives with neither a warning nor a Targets payload. The proxy expects every non-warning response to carry target sets; nil means the upstream violated the expected response shape.","triggerScenarios":"Send() on targetsServer is called with a response where res.GetTargets() == nil and res.GetWarning() == \"\" — an upstream TargetsAPI returned a response with no targets and no warning.","commonSituations":"A non-Thanos or buggy gRPC server registered as a TargetsAPI endpoint returning empty/nil payloads; version skew where an older binary responds with a different message shape.","solutions":["Identify which upstream endpoint produced the nil response (enable gRPC/logging per-endpoint) and check its version/health.","Upgrade or fix the offending TargetsAPI implementation so it returns Targets or a Warning, never neither.","Check for protobuf version skew between querier and providers (regenerate/align targetspb types).","As a caller, treat this endpoint as failing and exclude it from the store set."],"exampleFix":"// before\nresp, err := targetsClient.Targets(ctx, req)\n// after: guard at call site\nif resp != nil && resp.GetTargets() == nil && resp.GetWarning() == \"\" {\n    return nil, errors.New(\"upstream returned neither targets nor warning\")\n}","handlingStrategy":"validation","validationCode":"if res.GetWarning() == \"\" && res.GetTargets() == nil {\n    return errors.New(\"upstream sent neither targets nor warning\")\n}","typeGuard":"func validTargetsResponse(res *targetspb.TargetsResponse) bool {\n    return res.GetWarning() != \"\" || res.GetTargets() != nil\n}","tryCatchPattern":null,"preventionTips":["Pin compatible Thanos versions across querier and providers","Validate third-party TargetsAPI implementations against the proto contract","Add contract tests asserting non-nil Targets or Warning"],"tags":["grpc","unexpected-response-shape","thanos-targets"],"backgroundTag":"unexpected-response-shape","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}