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
- Change the variable to a supported scalar (sized int, bool, enum) or a struct/union.
- Move non-scalar data into a named struct (generate it with `dpgen type`) and reference that.
- Read the %T in the message to identify the offending kind.
- 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
- Never put pointers, arrays or function types in the config section.
- Model composite data as named structs regenerated via `dpgen type`.
- Run the kind guard in CI before invoking dpgen.
- Identify the offending kind from the %T message.
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
- generating config struct: %w
- variable %s has no type information, was the ELF built witho
- variable %s has no doc comment
- variable %s: converting tags to comments: %w
- variable %s: getting default Go value: %w
AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31).
Data as JSON: /api/errors/7bf0c04771d2b103.
Report an issue: GitHub.