{"record":{"id":"bf35ef90409190cf","repo":"thanos-io/thanos","slug":"res-getwarning","errorCode":null,"errorMessage":"res.GetWarning()","messagePattern":"res\\.GetWarning\\(\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/metadata/metadata.go","lineNumber":79,"sourceCode":"\ntype metadataServer struct {\n\t// This field just exist to pseudo-implement the unused methods of the interface.\n\tmetadatapb.Metadata_MetricMetadataServer\n\tctx context.Context\n\n\tmetric string\n\tlimit  int\n\n\twarnings    annotations.Annotations\n\tmetadataMap map[string][]metadatapb.Meta\n\tmu          sync.Mutex\n}\n\nfunc (srv *metadataServer) Send(res *metadatapb.MetricMetadataResponse) 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.GetMetadata() == nil {\n\t\treturn errors.New(\"no metadata\")\n\t}\n\n\t// If limit is set to 0, we don't need to add anything.\n\tif srv.limit == 0 {\n\t\treturn nil\n\t}\n\n\tsrv.mu.Lock()\n\tdefer srv.mu.Unlock()\n\tfor k, v := range res.GetMetadata().Metadata {\n\t\tif metadata, ok := srv.metadataMap[k]; !ok {\n\t\t\t// If limit is set and it is positive, we limit the size of the map.\n\t\t\tif srv.limit < 0 || srv.limit > 0 && len(srv.metadataMap) < srv.limit {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/metadata/metadata.go#L61-L97","documentation":"metadataServer.Send is the streaming response sink; when the response carries a Warning string instead of data, it records that warning into srv.warnings via errors.New(res.GetWarning()). It surfaces upstream warnings from the metadata service to the caller.","triggerScenarios":"The metadata stream delivers a MetricMetadataResponse with a non-empty warning field, typically generated when a downstream store error was downgraded under PartialResponseStrategy_WARNING.","commonSituations":"Partial metadata results because one store shard failed; timeouts on part of the metadata scan reported as warnings.","solutions":["Inspect srv.warnings after the call completes to see what was degraded","Fix the underlying store error described in the warning text","Use PartialResponseStrategy_ABORT if partial results with warnings are unacceptable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"metadata, warnings, err := proxy.MetricMetadata(ctx, req)\nif err == nil {\n    for _, w := range warnings {\n        log.Printf(\"metadata warning: %v\", w)\n    }\n}","preventionTips":["Always inspect the returned warnings slice, not just the error","Decide upfront whether partial results (WARNING strategy) are acceptable"],"tags":["grpc","streaming","warning"],"backgroundTag":"upstream-api-error","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"}