apache/beam · error

type is of kind

Error message

type is of kind %v

What it means

registerType recursively registers composite types (maps, arrays, slices, pointers). When registering a nested component (key or element) fails, the error is wrapped with "type is of kind %v" to indicate which parent kind the recursion came from.

Solutions

  1. Follow the wrapped error chain to the innermost cause and fix the child type that actually failed.
  2. Register a custom coder for the offending nested type.
  3. Simplify or restructure the nested type to schema-supported shapes.

Example fix

// before: failing nested element
type Wrapper struct { Items []*badElem }
// after
schema.RegisterCustomCoder(...) // or fix badElem's registration problem
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate nested element types before registration
if bad := firstUnsupported(t.Elem()); bad != nil {
    return fmt.Errorf("nested type %v unsupported", bad)
}

Try / catch

if err != nil {
    if strings.Contains(err.Error(), "type is of kind") {
        // inspect wrapped cause; fix the innermost type
    }
}

Prevention

When it happens

Trigger: registerType on a map/array/slice/pointer type whose Key() or Elem() type itself fails registration (e.g. element with unsupported kind or bad embedded field).

Common situations: Registering deeply nested types like []*unexportedEmbedded or map[string]badType where the failure is in the child; long wrap chains in the error message show the path of the offending nested type.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/c4234c141320ac25. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go:252

			return errors.Wrapf(err, "unable to convert LogicalType[%v] using provider for %v", t, lti)
		}
		if st == nil {
			continue
		}
		r.RegisterLogicalType(ToLogicalType(t.String(), t, st))
		r.addToMaps(st, t)
		return nil
	}

	switch t.Kind() {
	case reflect.Map:
		if err := r.registerType(t.Key(), seen); err != nil {
			return err
		}
		fallthrough
	case reflect.Array, reflect.Slice, reflect.Ptr:
		if err := r.registerType(t.Elem(), seen); err != nil {
			return errors.Wrapf(err, "type is of kind %v", t.Kind())
		}
		return nil
	case reflect.Interface, reflect.Func, reflect.Chan, reflect.Invalid, reflect.UnsafePointer, reflect.Uintptr:
		// Ignore these, as they can't be serialized.
		return nil
	case reflect.Complex64, reflect.Complex128:
		// TODO(BEAM-9615): Support complex number types.
		return nil
	case reflect.Struct: // What we expect here.
	default:
		rt, ok := reflectKindToTypeMap[t.Kind()]
		if !ok {
			// Kind is not listed, meaning it's an unlisted somehow, which means either the map
			// is missing something, or the above switch cases are missing something.
			return errors.Errorf("unlisted kind %v for type %v reached.", t.Kind(), t)
		}
		if t != rt {
			// It's only a logical type if it's not a built in primitive type, which is returned by the map.

View on GitHub (pinned to 12126d8942)