{"record":{"id":"f42c9873b745823e","repo":"temporalio/temporal","slug":"unknown-dc-redirection-policy-v","errorCode":null,"errorMessage":"Unknown DC redirection policy %v","messagePattern":"Unknown DC redirection policy (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/rpc/interceptor/dc_redirection_policy.go","lineNumber":106,"sourceCode":"\tenabledForNS dynamicconfig.BoolPropertyFnWithNamespaceFilter,\n\tselectedAPIsOnlyForNS dynamicconfig.BoolPropertyFnWithNamespaceFilter,\n\tnamespaceRegistry namespace.Registry,\n\tpolicy config.DCRedirectionPolicy,\n) DCRedirectionPolicy {\n\tswitch policy.Policy {\n\tcase DCRedirectionPolicyDefault:\n\t\t// default policy, noop\n\t\treturn NewNoopRedirectionPolicy(clusterMetadata.GetCurrentClusterName())\n\tcase DCRedirectionPolicyNoop:\n\t\treturn NewNoopRedirectionPolicy(clusterMetadata.GetCurrentClusterName())\n\tcase DCRedirectionPolicySelectedAPIsForwarding:\n\t\tcurrentClusterName := clusterMetadata.GetCurrentClusterName()\n\t\treturn NewSelectedAPIsForwardingPolicy(currentClusterName, enabledForNS, selectedAPIsOnlyForNS, namespaceRegistry)\n\tcase DCRedirectionPolicyAllAPIsForwarding:\n\t\tcurrentClusterName := clusterMetadata.GetCurrentClusterName()\n\t\treturn NewAllAPIsForwardingPolicy(currentClusterName, enabledForNS, selectedAPIsOnlyForNS, namespaceRegistry)\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Unknown DC redirection policy %v\", policy.Policy))\n\t}\n}\n\n// NewNoopRedirectionPolicy is DC redirection policy which does nothing\nfunc NewNoopRedirectionPolicy(currentClusterName string) *NoopRedirectionPolicy {\n\treturn &NoopRedirectionPolicy{\n\t\tcurrentClusterName: currentClusterName,\n\t}\n}\n\n// WithNamespaceIDRedirect redirect the API call based on namespace ID\nfunc (policy *NoopRedirectionPolicy) WithNamespaceIDRedirect(_ context.Context, _ namespace.ID, _ string, _ any, call func(string) error) error {\n\treturn call(policy.currentClusterName)\n}\n\n// WithNamespaceRedirect redirect the API call based on namespace name\nfunc (policy *NoopRedirectionPolicy) WithNamespaceRedirect(_ context.Context, _ namespace.Name, _ string, _ any, call func(string) error) error {\n\treturn call(policy.currentClusterName)","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/rpc/interceptor/dc_redirection_policy.go#L88-L124","documentation":"RedirectionPolicyGenerator constructs the DC (datacenter) redirection policy indicated by policy.Policy. It panics on any policy value other than Noop, AllAPIsForwarding, or SelectedAPIsForwarding, since there is no defined behavior for unknown policies.","triggerScenarios":"Calling NewRedirection with a DCRedirectionPolicy whose Policy field holds an invalid/unregistered enum value — e.g. after adding a new policy enum on the client without updating this generator, or a corrupt/mistyped dynamic config value.","commonSituations":"Version skew: newer cluster config sets a policy enum an older binary does not know; typo in config mapping to an undefined policy value.","solutions":["Use a supported policy: DCRedirectionPolicyNoop, DCRedirectionPolicyAllAPIsForwarding, or DCRedirectionPolicySelectedAPIsForwarding","Fix the dynamic config/cluster metadata supplying the unknown policy value","Upgrade the binary so it recognizes the newer policy enum"],"exampleFix":"// before\npolicy := dcRedirectionPolicy{Policy: 99}\ngenerator := rpc.NewRedirection(policy, ...)\n// after\npolicy := dcRedirectionPolicy{Policy: enumspb.DCRedirectionPolicyNoop}\ngenerator := rpc.NewRedirection(policy, ...)","handlingStrategy":"validation","validationCode":"switch policy.Policy {\ncase enumspb.DCRedirectionPolicyNoop,\n     enumspb.DCRedirectionPolicyAllAPIsForwarding,\n     enumspb.DCRedirectionPolicySelectedAPIsForwarding:\n    // ok\ndefault:\n    return fmt.Errorf(\"unsupported DC redirection policy %v\", policy.Policy)\n}","typeGuard":null,"tryCatchPattern":"func() (p rpc.RedirectionPolicy) {\n    defer func() {\n        if recover() != nil { p = rpc.NewNoopRedirectionPolicy(clusterName) }\n    }()\n    return generator()\n}()","preventionTips":["Only configure known policy enum values in dynamic config","Align client/server versions before introducing new policy enums","Fail fast at config load with a clear message for unknown policies"],"tags":["go","panic","rpc","interceptor","config"],"backgroundTag":"unknown-enum-policy","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}