temporalio/temporal · error · sadefs.ErrInvalidType

%w: %v

Error message

%w: %v

What it means

DecodeValue wraps sadefs.ErrInvalidType when the effective INDEXED_VALUE_TYPE is UNSPECIFIED. It first tries GetMetadataType(value) to infer the type from payload metadata; if that also yields UNSPECIFIED, there is no way to know how to decode the payload, so it fails. This guards against decoding visibility-store payloads that carry no type metadata.

Source

Thrown at common/searchattribute/sadefs/encode_value.go:49

		panic(err)
	}
	return valPayload
}

// DecodeValue decodes search attribute value from Payload using (in order):
// 1. passed type t.
// 2. type from MetadataType field, if t is not specified.
// allowList allows list of values when it's not keyword list type.
func DecodeValue(
	value *commonpb.Payload,
	t enumspb.IndexedValueType,
	allowList bool,
) (any, error) {
	if t == enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED {
		t = GetMetadataType(value)
	}
	if t == enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED {
		return nil, fmt.Errorf("%w: %v", ErrInvalidType, t)
	}

	switch t {
	case enumspb.INDEXED_VALUE_TYPE_BOOL:
		return decodeValueTyped[bool](value, allowList)
	case enumspb.INDEXED_VALUE_TYPE_DATETIME:
		return decodeValueTyped[time.Time](value, allowList)
	case enumspb.INDEXED_VALUE_TYPE_DOUBLE:
		return decodeValueTyped[float64](value, allowList)
	case enumspb.INDEXED_VALUE_TYPE_INT:
		return decodeValueTyped[int64](value, allowList)
	case enumspb.INDEXED_VALUE_TYPE_KEYWORD:
		return validateStrings(decodeValueTyped[string](value, allowList))
	case enumspb.INDEXED_VALUE_TYPE_TEXT:
		return validateStrings(decodeValueTyped[string](value, allowList))
	case enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST:
		return validateStrings(decodeValueTyped[[]string](value, false))
	default:

View on GitHub (pinned to bde624efd1)

Solutions

  1. Encode values with sadefs.EncodeValue so type metadata is attached to the payload.
  2. Pass an explicit non-UNSPECIFIED enumspb.IndexedValueType to DecodeValue instead of relying on metadata inference.
  3. Verify the payload metadata retains the search-attribute type key through any intermediate storage or copying.

Example fix

// before
val, err := sadefs.DecodeValue(payload, enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED, false) // metadata missing
// after
val, err := sadefs.DecodeValue(payload, enumspb.INDEXED_VALUE_TYPE_KEYWORD, false)
Defensive patterns

Strategy: validation

Validate before calling

if t == enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED && sadefs.GetMetadataType(payload) == enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED {
    return fmt.Errorf("payload has no search attribute type metadata")
}

Try / catch

if errors.Is(err, sadefs.ErrInvalidType) { /* re-encode or request explicit type from caller */ }

Prevention

When it happens

Trigger: Calling DecodeValue with an INDEXED_VALUE_TYPE_UNSPECIFIED type on a payload whose metadata also lacks a search-attribute type key — e.g. a payload written without EncodeValue or with metadata stripped.

Common situations: Custom visibility store integrations that construct payloads manually; payloads produced by an older SDK version that did not stamp type metadata; copying payloads between stores losing metadata fields.

Related errors


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