{"record":{"id":"28a791892800b818","repo":"jaegertracing/jaeger","slug":"could-not-convert-sampling-strategy-type","errorCode":null,"errorMessage":"could not convert sampling strategy type","messagePattern":"could not convert sampling strategy type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/converter/thrift/jaeger/sampling_from_domain.go","lineNumber":89,"sourceCode":"\nfunc convertOperationFromDomain(s *api_v2.OperationSamplingStrategy) *sampling.OperationSamplingStrategy {\n\tif s == nil {\n\t\treturn nil\n\t}\n\treturn &sampling.OperationSamplingStrategy{\n\t\tOperation:             s.GetOperation(),\n\t\tProbabilisticSampling: convertProbabilisticFromDomain(s.GetProbabilisticSampling()),\n\t}\n}\n\nfunc convertStrategyTypeFromDomain(s api_v2.SamplingStrategyType) (sampling.SamplingStrategyType, error) {\n\tswitch s {\n\tcase api_v2.SamplingStrategyType_PROBABILISTIC:\n\t\treturn sampling.SamplingStrategyType_PROBABILISTIC, nil\n\tcase api_v2.SamplingStrategyType_RATE_LIMITING:\n\t\treturn sampling.SamplingStrategyType_RATE_LIMITING, nil\n\tdefault:\n\t\treturn sampling.SamplingStrategyType_PROBABILISTIC, errors.New(\"could not convert sampling strategy type\")\n\t}\n}\n","sourceCodeStart":71,"sourceCodeEnd":92,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/converter/thrift/jaeger/sampling_from_domain.go#L71-L92","documentation":"convertStrategyTypeFromDomain returns this error when the domain sampling strategy type is neither PROBABILISTIC nor RATE_LIMITING, i.e. an unknown/unsupported enum value for the legacy Thrift representation.","triggerScenarios":"ConvertSamplingResponseFromDomain receives an api_v2.SamplingStrategyType outside the two known values (e.g. an enum value from a newer IDL or a zero/unset type in a hand-built struct); the switch default errors.","commonSituations":"Deserializing a sampling response produced by a newer service using an added enum value; constructing the strategy struct manually and leaving StrategyType unset (0 fallback in proto2 enums); IDL version skew between client and server.","solutions":["Set the strategy type explicitly to PROBABILISTIC or RATE_LIMITING before conversion","Regenerate/upgrade the api_v2 and thrift bindings together so enum sets match","Treat the error as a protocol-compat signal: log and fall back to a default strategy in the caller"],"exampleFix":"// before\nresp := &api_v2.SamplingStrategyResponse{} // StrategyType unset\n// after\nresp := &api_v2.SamplingStrategyResponse{\n  StrategyType: api_v2.SamplingStrategyType_PROBABILISTIC,\n}","handlingStrategy":"type-guard","validationCode":"switch s.StrategyType {\ncase api_v2.SamplingStrategyType_PROBABILISTIC, api_v2.SamplingStrategyType_RATE_LIMITING:\n    // ok\ndefault:\n    return errors.New(\"unsupported sampling strategy type\")\n}\nresp, err := jaegerconv.ConvertSamplingResponseFromDomain(s)","typeGuard":"func convertibleStrategyType(t api_v2.SamplingStrategyType) bool {\n    return t == api_v2.SamplingStrategyType_PROBABILISTIC ||\n        t == api_v2.SamplingStrategyType_RATE_LIMITING\n}","tryCatchPattern":"resp, err := ConvertSamplingResponseFromDomain(s)\nif err != nil {\n    if strings.Contains(err.Error(), \"could not convert sampling strategy type\") {\n        return defaultSamplingResponse(), nil\n    }\n    return nil, err\n}","preventionTips":["Always set StrategyType explicitly in the domain response","Keep api_v2 and thrift enum bindings version-aligned","Fall back to a default strategy on unknown enum values"],"tags":["go","thrift","sampling","enum","conversion"],"backgroundTag":"unsupported-enum-value","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}