temporalio/temporal · error

failed to parse archetypeID: %w

Error message

failed to parse archetypeID: %w

What it means

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.

Source

Thrown at service/worker/common/chasm_util.go:38

	}

	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

  1. Validate that writers store only canonical decimal uint32 strings in TemporalNamespaceDivision.
  2. Inspect the offending value in persistence and correct it to the intended archetype ID (a valid uint32 decimal).
  3. Ensure consistent CHASM library versions across services so the field's format contract (digit-prefixed numeric string) is honored.
  4. Handle the returned UnspecifiedArchetypeID gracefully in the caller so a malformed ID degrades to unspecified rather than failing the workflow task.

Example fix

// before
nsDivisionStr = "v12" // digit-prefixed but not numeric
// after
nsDivisionStr = "12" // valid uint32 decimal parsed by strconv.ParseUint(s,10,32)
Defensive patterns

Strategy: validation

Validate before calling

func validArchetypeIDString(s string) error {
  if _, err := strconv.ParseUint(s, 10, 32); err != nil {
    return fmt.Errorf("not a uint32 archetype id: %q", s)
  }
  return nil
}

Type guard

func isArchetypeIDString(s string) bool {
  _, err := strconv.ParseUint(s, 10, 32)
  return err == nil
}

Try / catch

archetypeID, err := common.ArchetypeIDFromExecutionInfo(info)
if err != nil {
  logger.Warn("malformed archetype id; using unspecified", tag.Error(err))
  archetypeID = chasm.UnspecifiedArchetypeID
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of temporalio/temporal@bde624efd1 (2026-09-01). Data as JSON: /api/errors/0a69266eafeb1d25. Report an issue: GitHub.