{"record":{"id":"0a69266eafeb1d25","repo":"temporalio/temporal","slug":"failed-to-parse-archetypeid-w","errorCode":null,"errorMessage":"failed to parse archetypeID: %w","messagePattern":"failed to parse archetypeID: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/worker/common/chasm_util.go","lineNumber":38,"sourceCode":"\t}\n\n\tnsDivisionPayload, ok := indexedField[sadefs.TemporalNamespaceDivision]\n\tif !ok {\n\t\treturn chasm.WorkflowArchetypeID, nil\n\t}\n\n\tvar nsDivisionStr string\n\tif err := payload.Decode(nsDivisionPayload, &nsDivisionStr); err != nil {\n\t\treturn chasm.UnspecifiedArchetypeID, fmt.Errorf(\"failed to decode TemporalNamespaceDivision field: %w\", err)\n\t}\n\n\tif len(nsDivisionStr) == 0 || !unicode.IsDigit(rune(nsDivisionStr[0])) {\n\t\treturn chasm.WorkflowArchetypeID, nil\n\t}\n\n\tarchetypeID, err := strconv.ParseUint(nsDivisionStr, 10, 32)\n\tif err != nil {\n\t\treturn chasm.UnspecifiedArchetypeID, fmt.Errorf(\"failed to parse archetypeID: %w\", err)\n\t}\n\n\treturn chasm.ArchetypeID(archetypeID), nil\n}\n","sourceCodeStart":20,"sourceCodeEnd":43,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/worker/common/chasm_util.go#L20-L43","documentation":"After decoding the TemporalNamespaceDivision payload, ArchetypeIDFromExecutionInfo parses leading-digit strings as a uint32 archetype ID via strconv.ParseUint. If the string is not a valid unsigned integer (or exceeds 32 bits), this wrapped error is returned with UnspecifiedArchetypeID.","triggerScenarios":"The namespace-division string starts with a digit (so the digit fast-path is taken) but the full string is not a parseable uint32 — e.g. \"12abc\", \"99999999999\" (>32-bit), \"-1\" handled oddly, or whitespace/garbage data in the field.","commonSituations":"Corrupt or hand-edited persistence data; a writer storing an oversized or malformed numeric ID; encoding drift between CHASM versions where the field semantics changed from numeric ID to another digit-prefixed value.","solutions":["Validate that writers store only canonical decimal uint32 strings in TemporalNamespaceDivision.","Inspect the offending value in persistence and correct it to the intended archetype ID (a valid uint32 decimal).","Ensure consistent CHASM library versions across services so the field's format contract (digit-prefixed numeric string) is honored.","Handle the returned UnspecifiedArchetypeID gracefully in the caller so a malformed ID degrades to unspecified rather than failing the workflow task."],"exampleFix":"// before\nnsDivisionStr = \"v12\" // digit-prefixed but not numeric\n// after\nnsDivisionStr = \"12\" // valid uint32 decimal parsed by strconv.ParseUint(s,10,32)","handlingStrategy":"validation","validationCode":"func validArchetypeIDString(s string) error {\n  if _, err := strconv.ParseUint(s, 10, 32); err != nil {\n    return fmt.Errorf(\"not a uint32 archetype id: %q\", s)\n  }\n  return nil\n}","typeGuard":"func isArchetypeIDString(s string) bool {\n  _, err := strconv.ParseUint(s, 10, 32)\n  return err == nil\n}","tryCatchPattern":"archetypeID, err := common.ArchetypeIDFromExecutionInfo(info)\nif err != nil {\n  logger.Warn(\"malformed archetype id; using unspecified\", tag.Error(err))\n  archetypeID = chasm.UnspecifiedArchetypeID\n}","preventionTips":["Store archetype IDs as canonical decimal uint32 strings only.","Reject digit-prefixed non-numeric strings at write time.","Add round-trip tests writing and reading the namespace division field.","Keep CHASM writer/reader versions aligned."],"tags":["go","chasm","parse-error","strconv"],"backgroundTag":"numeric-parse-failed","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}