go-delve/delve · error
key type not supported %T
Error message
key type not supported %T
What it means
The Starlark mapping wrapper over a Delve variable (mapIndex/Get) only supports string, bool and structVariable (variable) keys; any other Starlark key type (int, tuple, None, etc.) is rejected when evaluating the map index in the debuggee.
Source
Thrown at pkg/terminal/starbind/conv.go:543
func (v mapVariableAsStarlarkValue) Type() string {
return v.v.Type
}
func (v mapVariableAsStarlarkValue) Get(key starlark.Value) (starlark.Value, bool, error) {
var keyExpr string
switch key := key.(type) {
case starlark.Int:
keyExpr = key.String()
case starlark.Float:
keyExpr = fmt.Sprintf("%g", float64(key))
case starlark.String:
keyExpr = fmt.Sprintf("%q", string(key))
case starlark.Bool:
keyExpr = fmt.Sprintf("%v", bool(key))
case structVariableAsStarlarkValue:
keyExpr = varAddrExpr(key.v)
default:
return starlark.None, false, fmt.Errorf("key type not supported %T", key)
}
v2 := v.env.autoLoad(fmt.Sprintf("%s[%s]", varAddrExpr(v.v), keyExpr))
r, err := v.env.variableValueToStarlarkValue(v2, false)
if err != nil {
if err.Error() == "key not found" {
return starlark.None, false, nil
}
return starlark.None, false, err
}
return r, true, nil
}
func (v mapVariableAsStarlarkValue) Items() []starlark.Tuple {
r := make([]starlark.Tuple, 0, len(v.v.Children)/2)
for i := 0; i < len(v.v.Children); i += 2 {
r = append(r, mapStarlarkTupleAt(v.v, v.env, i))
}View on GitHub (pinned to a23773e6c3)
Solutions
- Use a string key: m["key"] — for integer keys quote them so they are sent as an expression, e.g. m[str(42)] if supported, or use m['%d' % 42] form
- Index the map directly via the debugger expression instead: env autoLoad of var[expr]
- Restructure the script to iterate keys via the debugger rather than indexing by native Starlark ints
Example fix
# before m[42] # int key not supported # after m[str(42)] # or 'm[42]' evaluated as debugger expression
Defensive patterns
Strategy: type-guard
Validate before calling
if not isinstance(key, (str, bool)):
raise TypeError("map index key must be str or bool, got %s" % type(key)) Type guard
def is_supported_key(k):
return isinstance(k, (str, bool)) or hasattr(k, 'v') # structVariableAsStarlarkValue Try / catch
try:
v = m[key]
except Exception as e:
if "key type not supported" in str(e):
v = m[str(key)] # re-index as string expression
else:
raise Prevention
- Always use string (or bool) keys when indexing debugger map variables
- Convert numeric keys with str()/format before indexing
- Prefer debugger-expression indexing for non-string key types
When it happens
Trigger: `some_map_var[42]` or `some_map_var[(1,2)]` in a Starlark script where the Delve variable is a Go map whose keys must be expressed as an evaluated expression string.
Common situations: Indexing Go maps with numeric literals in scripts; Delve evaluates the index in the target process, so keys must be round-trippable expressions.
Related errors
- can not assign to %T.%q: %v
- can not assign big integer to %T.%q
- can not assign value of type %T to %T.%q
- error setting argument %q to %s: %v
- error setting argument %q: can not convert %s to %s: %s
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/4f59a72c320574bf.
Report an issue: GitHub.