{"record":{"id":"d93c33d87a187aeb","repo":"temporalio/temporal","slug":"unknown-transaction-policy-v","errorCode":null,"errorMessage":"unknown transaction policy: %v","messagePattern":"unknown transaction policy: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/history/workflow/mutable_state_impl.go","lineNumber":8467,"sourceCode":"\t\t\t\t\t\tNextEventID:            nextEventID,\n\t\t\t\t\t\tTaskEquivalents:        replicationTasks,\n\t\t\t\t\t\tLastVersionHistoryItem: lastVersionHistoryItem,\n\t\t\t\t\t}\n\n\t\t\t\t\tif ms.dbRecordVersion == 1 {\n\t\t\t\t\t\tsyncVersionedTransitionTask.IsFirstTask = true\n\t\t\t\t\t}\n\n\t\t\t\t\t// versioned transition updated in the transaction\n\t\t\t\t\tms.InsertTasks[tasks.CategoryReplication] = append(\n\t\t\t\t\t\tms.InsertTasks[tasks.CategoryReplication],\n\t\t\t\t\t\tsyncVersionedTransitionTask,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\tcase historyi.TransactionPolicyPassive:\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"unknown transaction policy: %v\", transactionPolicy))\n\t\t}\n\t} else if isWorkflow {\n\t\tms.InsertTasks[tasks.CategoryReplication] = append(\n\t\t\tms.InsertTasks[tasks.CategoryReplication],\n\t\t\treplicationTasks...,\n\t\t)\n\t} else {\n\t\treturn softassert.UnexpectedInternalErr(ms.logger, \"state-based replication not enabled for chasm execution\", nil)\n\t}\n\n\tif transactionPolicy == historyi.TransactionPolicyPassive &&\n\t\tlen(ms.InsertTasks[tasks.CategoryReplication]) > 0 {\n\t\treturn softassert.UnexpectedInternalErr(\n\t\t\tms.logger,\n\t\t\t\"should not generate replication task when close transaction as passive\",\n\t\t\tnil,\n\t\t)\n\t}","sourceCodeStart":8449,"sourceCodeEnd":8485,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/history/workflow/mutable_state_impl.go#L8449-L8485","documentation":"During mutable-state task generation, code that applies a historyi.TransactionPolicy switches over the policy value (Active, Passive, ...) and panics on anything else with \"unknown transaction policy: %v\". TransactionPolicy tells the history service whether this node is the active cluster (should emit tasks/replication) or passive. A value outside the known set means a new enum member was added without updating this switch, or the policy was constructed incorrectly.","triggerScenarios":"Generating replication tasks inside an HSM/transaction update path (around line 8467) when the transactionPolicy parameter holds an unrecognized value — e.g. a newly added TransactionPolicy constant not yet handled in this switch, or a policy passed through from an incompatible caller.","commonSituations":"Version skew where one binary produces a new policy value another binary's switch doesn't handle; internal refactoring bugs adding a new policy without updating all switches.","solutions":["Upgrade all history service binaries to the same version so every TransactionPolicy value is handled everywhere.","Search the codebase for the new TransactionPolicy constant and add the missing case to this switch.","Audit the caller that passed the policy value to confirm it isn't passing an uninitialized/zero-value policy.","If it reproduces on a single version, file a bug with the printed policy value."],"exampleFix":"// before\ncase historyi.TransactionPolicyPassive:\ndefault:\n    panic(fmt.Sprintf(\"unknown transaction policy: %v\", transactionPolicy))\n// after\ncase historyi.TransactionPolicyPassive:\ncase historyi.TransactionPolicyActive: // handle new value explicitly\ndefault:\n    panic(fmt.Sprintf(\"unknown transaction policy: %v\", transactionPolicy))","handlingStrategy":"validation","validationCode":"// Before invoking task generation, assert the policy is one of the known values:\nif transactionPolicy != historyi.TransactionPolicyActive &&\n    transactionPolicy != historyi.TransactionPolicyPassive {\n    return fmt.Errorf(\"unrecognized transaction policy %v\", transactionPolicy)\n}","typeGuard":"func knownTransactionPolicy(p historyi.TransactionPolicy) bool {\n    switch p {\n    case historyi.TransactionPolicyActive, historyi.TransactionPolicyPassive:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Run identical server versions on all history nodes.","When adding a TransactionPolicy constant, update every switch in mutable_state_impl.go in the same PR.","Never construct TransactionPolicy from raw integers.","Keep unit tests that exhaustively enumerate TransactionPolicy values across all switch sites."],"tags":["go","panic","transaction-policy","switch-exhaustiveness"],"backgroundTag":"invalid-enum-value","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}