{"record":{"id":"2a31e1fa68bcc528","repo":"go-delve/delve","slug":"value-not-loaded","errorCode":null,"errorMessage":"value not loaded","messagePattern":"value not loaded","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/starbind/conv.go","lineNumber":250,"sourceCode":"\t\treturn starlark.String(varAddrExpr(&v2)), nil\n\t}\n\n\treturn v.env.variableValueToStarlarkValue(&v2, true)\n}\n\nfunc varAddrExpr(v *api.Variable) string {\n\treturn fmt.Sprintf(\"(*(*%q)(%#x))\", v.Type, v.Addr)\n}\n\nfunc (env *Env) variableValueToStarlarkValue(v *api.Variable, top bool) (starlark.Value, error) {\n\tif !top && v.Addr == 0 && v.Value == \"\" {\n\t\treturn starlark.None, nil\n\t}\n\n\tswitch v.Kind {\n\tcase reflect.Struct:\n\t\tif v.Len != 0 && len(v.Children) == 0 {\n\t\t\treturn starlark.None, errors.New(\"value not loaded\")\n\t\t}\n\t\treturn structVariableAsStarlarkValue{v: v, env: env}, nil\n\tcase reflect.Slice, reflect.Array:\n\t\tif v.Len != 0 && len(v.Children) == 0 {\n\t\t\treturn starlark.None, errors.New(\"value not loaded\")\n\t\t}\n\t\treturn sliceVariableAsStarlarkValue{v: v, env: env}, nil\n\tcase reflect.Map:\n\t\tif v.Len != 0 && len(v.Children) == 0 {\n\t\t\treturn starlark.None, errors.New(\"value not loaded\")\n\t\t}\n\t\treturn mapVariableAsStarlarkValue{v: v, env: env}, nil\n\tcase reflect.String:\n\t\treturn starlark.String(v.Value), nil\n\tcase reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:\n\t\tn, _ := strconv.ParseInt(api.ExtractIntValue(v.Value), 0, 64)\n\t\treturn starlark.MakeInt64(n), nil\n\tcase reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint, reflect.Uintptr:","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/starbind/conv.go#L232-L268","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (script assumes children are present)\nval := scope[\"myStruct\"]\nprint(val.Field)\n// after (reload the value via a command that loads children)\ncfg := {\"MaxVariableRecurse\": -1}\ndlv_command(\"print myStruct\")  // evaluate with children loaded before scripting access","handlingStrategy":"type-guard","validationCode":"def is_loaded_struct(v):\n    return v.Kind == \"struct\" and (v.Len == 0 or len(v.Children) > 0)","typeGuard":"def is_loaded_struct(v):\n    return type(v) == \"structVariableAsStarlarkValue\" or (hasattr(v, \"Len\") and (v.Len == 0 or len(v.Children) > 0))","tryCatchPattern":"try:\n    val = to_starlark(var)\nexcept Exception as e:\n    if \"value not loaded\" in str(e):\n        dlv_command(\"print \" + name)  # reload with children\n        val = to_starlark(scope[name])\n    else:\n        raise","preventionTips":["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"],"tags":["starlark","scripting","variables"],"backgroundTag":"value-not-loaded","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}