go-delve/delve · error
value not loaded
Error message
value not loaded
What it means
This error comes from variableValueToStarlarkValue in Delve's Starlark scripting bridge. When converting an api.Variable of kind Struct to a Starlark value, a non-empty struct whose Children slice is empty means its fields were never loaded from the debuggee (the variable was evaluated without child loading). Delve refuses to silently expose an empty struct, so it returns 'value not loaded'.
Source
Thrown at pkg/terminal/starbind/conv.go:250
return starlark.String(varAddrExpr(&v2)), nil
}
return v.env.variableValueToStarlarkValue(&v2, true)
}
func varAddrExpr(v *api.Variable) string {
return fmt.Sprintf("(*(*%q)(%#x))", v.Type, v.Addr)
}
func (env *Env) variableValueToStarlarkValue(v *api.Variable, top bool) (starlark.Value, error) {
if !top && v.Addr == 0 && v.Value == "" {
return starlark.None, nil
}
switch v.Kind {
case reflect.Struct:
if v.Len != 0 && len(v.Children) == 0 {
return starlark.None, errors.New("value not loaded")
}
return structVariableAsStarlarkValue{v: v, env: env}, nil
case reflect.Slice, reflect.Array:
if v.Len != 0 && len(v.Children) == 0 {
return starlark.None, errors.New("value not loaded")
}
return sliceVariableAsStarlarkValue{v: v, env: env}, nil
case reflect.Map:
if v.Len != 0 && len(v.Children) == 0 {
return starlark.None, errors.New("value not loaded")
}
return mapVariableAsStarlarkValue{v: v, env: env}, nil
case reflect.String:
return starlark.String(v.Value), nil
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
n, _ := strconv.ParseInt(api.ExtractIntValue(v.Value), 0, 64)
return starlark.MakeInt64(n), nil
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint, reflect.Uintptr:View on GitHub (pinned to a23773e6c3)
Solutions
- Re-fetch the variable so children are loaded: use the dlv_command builtin to run a command that fully evaluates the variable, or configure the evaluation to load child values.
- Increase the load/config settings (MaxLoadValue / MaxVariableRecurse) so struct fields are populated before conversion.
- Guard scripts: check len(v.Children) == 0 and v.Len != 0 before treating a struct variable as usable, and reload otherwise.
Example fix
// before (script assumes children are present)
val := scope["myStruct"]
print(val.Field)
// after (reload the value via a command that loads children)
cfg := {"MaxVariableRecurse": -1}
dlv_command("print myStruct") // evaluate with children loaded before scripting access Defensive patterns
Strategy: type-guard
Validate before calling
def is_loaded_struct(v):
return v.Kind == "struct" and (v.Len == 0 or len(v.Children) > 0) Type guard
def is_loaded_struct(v):
return type(v) == "structVariableAsStarlarkValue" or (hasattr(v, "Len") and (v.Len == 0 or len(v.Children) > 0)) Try / catch
try:
val = to_starlark(var)
except Exception as e:
if "value not loaded" in str(e):
dlv_command("print " + name) # reload with children
val = to_starlark(scope[name])
else:
raise Prevention
- Evaluate variables with settings that load children (MaxLoadValue/MaxVariableRecurse)
- Call dlv_command("print x") before scripted access to struct variables
- Check Len/Children before assuming a struct is populated
When it happens
Trigger: In a Starlark script, accessing a struct-typed variable obtained via an API call that did not load children (e.g. a variable returned with follow-pointers/depth settings that truncated children, or a large struct returned unloaded), then passing it through the conversion used by mapStarlarkTupleAt.
Common situations: Scripts that iterate map values or tuple entries whose struct members were not recursively loaded; using variables fetched with MaxLoadValue settings that skip children; deeply nested structs where only the top level was loaded.
Related errors
- not hashable
- cycle in load graph
- argument of dlv_command is not a string
- wrong number of arguments
- argument of read_file was not a string
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/2a31e1fa68bcc528.
Report an issue: GitHub.