cilium/cilium · error

unsupported type %T

Error message

unsupported type %T

What it means

varGoValue handles only *btf.Int, *btf.Enum, *btf.Union and *btf.Struct kinds when synthesizing a default Go literal. Any other underlying type (pointer, array, function, etc.) cannot get a default value, so it fails naming the concrete Go type via %T.

Source

Thrown at tools/dpgen/config.go:269

			default:
				return nil, fmt.Errorf("unsupported unsigned integer size %d", t.Size)
			}
		case btf.Bool:
			return getValue[bool](v)
		default:
			return nil, fmt.Errorf("unsupported encoding %v", t.Encoding)
		}

	case *btf.Union:
		needUtils = true
		return getCastValue(t.Name, t.Size, v, typesPkg)

	case *btf.Struct:
		needUtils = true
		return getCastValue(t.Name, t.Size, v, typesPkg)

	default:
		return "", fmt.Errorf("unsupported type %T", t)
	}
}

func getValue[T comparable](v *ebpf.VariableSpec) (out T, err error) {
	if err := v.Get(&out); err != nil {
		return out, fmt.Errorf("getting value: %w", err)
	}
	return out, nil
}

// getCastValue gets the default value of a variable and returns a string of Go
// code that casts the value to the appropriate Go type using the cast() helper
// provided by util_generated.go.
//
//	cast[uint32]([]byte{0x01, 0x00, 0x00, 0x00}
func getCastValue(name string, size uint32, v *ebpf.VariableSpec, typesPkg string) (string, error) {
	b := make([]byte, size)
	if err := v.Get(b); err != nil {

View on GitHub (pinned to ac7b90affa)

Solutions

  1. Change the variable to a supported scalar (sized int, bool, enum) or a struct/union.
  2. Move non-scalar data into a named struct (generate it with `dpgen type`) and reference that.
  3. Read the %T in the message to identify the offending kind.
  4. Add a case to varGoValue if the kind must be supported.

Example fix

// before
const char *name;
// after
struct config { char name[64]; }; // use struct in config
Defensive patterns

Strategy: type-guard

Validate before calling

switch btf.UnderlyingType(v.Type).(type) {
case *btf.Int, *btf.Enum, *btf.Struct, *btf.Union:
    // ok
default:
    return fmt.Errorf("%s: kind has no default Go value", v.Name)
}

Type guard

func supportsGoValue(t btf.Type) bool {
    switch btf.UnderlyingType(t).(type) {
    case *btf.Int, *btf.Enum, *btf.Struct, *btf.Union:
        return true
    default:
        return false
    }
}

Prevention

When it happens

Trigger: Declaring a config variable whose underlying BTF type is not an int/enum/struct/union — e.g. const char *name or int arr[16] — and running dpgen.

Common situations: Developers adding pointers or arrays to the bpf config map and regenerating, expecting dpgen to cope.

Related errors


AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31). Data as JSON: /api/errors/7bf0c04771d2b103. Report an issue: GitHub.