temporalio/temporal · error
failed to decode TemporalNamespaceDivision field: %w
Error message
failed to decode TemporalNamespaceDivision field: %w
What it means
ArchetypeIDFromExecutionInfo extracts a CHASM archetype ID from the workflow execution info's TemporalNamespaceDivision payload. If the raw payload cannot be decoded into a string (corrupt or wrongly-encoded data), the function returns UnspecifiedArchetypeID along with this wrapped error.
Source
Thrown at service/worker/common/chasm_util.go:29
"go.temporal.io/server/common/searchattribute/sadefs"
)
func ArchetypeIDFromExecutionInfo(
executionInfo *workflowpb.WorkflowExecutionInfo,
) (chasm.ArchetypeID, error) {
indexedField := executionInfo.SearchAttributes.GetIndexedFields()
if indexedField == nil {
return chasm.WorkflowArchetypeID, nil
}
nsDivisionPayload, ok := indexedField[sadefs.TemporalNamespaceDivision]
if !ok {
return chasm.WorkflowArchetypeID, nil
}
var nsDivisionStr string
if err := payload.Decode(nsDivisionPayload, &nsDivisionStr); err != nil {
return chasm.UnspecifiedArchetypeID, fmt.Errorf("failed to decode TemporalNamespaceDivision field: %w", err)
}
if len(nsDivisionStr) == 0 || !unicode.IsDigit(rune(nsDivisionStr[0])) {
return chasm.WorkflowArchetypeID, nil
}
archetypeID, err := strconv.ParseUint(nsDivisionStr, 10, 32)
if err != nil {
return chasm.UnspecifiedArchetypeID, fmt.Errorf("failed to parse archetypeID: %w", err)
}
return chasm.ArchetypeID(archetypeID), nil
}
View on GitHub (pinned to bde624efd1)
Solutions
- Inspect the payload's encoding/metadata and re-encode it as the expected plain string before storage.
- Ensure all services in the cluster run compatible versions so the TemporalNamespaceDivision field is written and read consistently.
- Treat UnspecifiedArchetypeID + error as a fallback (defaults to WorkflowArchetypeID only for empty/non-digit strings) and alert on the decode failure to catch data corruption early.
- If the payload is unrecoverable, clear/rewrite the field via the appropriate migration so future writes use the string encoding.
Example fix
// before
payload := payloads.NewEncodedValue(raw, "unknown-encoding")
info.NamespaceDivision = payload // fails to decode later
// after
b, _ := proto.Marshal(&commonpb.Payload{Metadata: map[string]string{"encoding": encodingtype.Raw}, Data: []byte(nsDivision)})
info.NamespaceDivision = payloads.NewData(b) // decodable string payload Defensive patterns
Strategy: type-guard
Validate before calling
func nsDivisionDecodable(p *commonpb.Payload) error {
var s string
if err := payload.Decode(p, &s); err != nil {
return err
}
return nil
} Type guard
func isStringPayload(p *commonpb.Payload) bool {
enc := p.GetMetadata()["encoding"]
return enc == encodingtype.String || enc == encodingtype.Json
} Try / catch
archetypeID, err := common.ArchetypeIDFromExecutionInfo(info)
if err != nil {
logger.Warn("namespace division payload undecodable; defaulting archetype", tag.Error(err))
archetypeID = chasm.WorkflowArchetypeID
} Prevention
- Write TemporalNamespaceDivision only as a plain string payload.
- Keep CHASM library versions consistent across all services that write this field.
- Avoid manual persistence edits to payload fields.
- Monitor decode errors as an early signal of data corruption or version skew.
When it happens
Trigger: Calling ArchetypeIDFromExecutionInfo on an execution info whose namespace-division payload was written with a non-string encoding (e.g. binary/protobuf bytes instead of a plain string payload) or is corrupted in persistence.
Common situations: Mixed-version clusters where an older writer encoded the field differently than the current decoder expects; data migrations or manual persistence edits; CHASM experiments flag differences between services writing and reading the field.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- ErrInvalidTransition
- failed to deserialize component: %w
- failed to deserialize data: %w
- %w: zombie workflow cannot be updated
- ErrStaleReference
AI-assisted analysis of temporalio/temporal@bde624efd1 (2026-09-01).
Data as JSON: /api/errors/41f5804bc27edd1a.
Report an issue: GitHub.