{"record":{"id":"fe2705108aea652a","repo":"go-delve/delve","slug":"error-setting-argument-q-to-s-v","errorCode":null,"errorMessage":"error setting argument %q to %s: %v","messagePattern":"error setting argument %q to (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/starbind/conv.go","lineNumber":628,"sourceCode":"\n\tit.cur += 2\n\treturn true\n}\n\n// unmarshalStarlarkValue unmarshals a starlark.Value 'val' into a Go variable 'dst'.\n// This works similarly to encoding/json.Unmarshal and similar functions,\n// but instead of getting its input from a byte buffer, it uses a\n// starlark.Value.\nfunc unmarshalStarlarkValue(val starlark.Value, dst any, path string) error {\n\treturn unmarshalStarlarkValueIntl(val, reflect.ValueOf(dst), path)\n}\n\nfunc unmarshalStarlarkValueIntl(val starlark.Value, dst reflect.Value, path string) (err error) {\n\tdefer func() {\n\t\t// catches reflect panics\n\t\tierr := recover()\n\t\tif ierr != nil {\n\t\t\terr = fmt.Errorf(\"error setting argument %q to %s: %v\", path, val, ierr)\n\t\t}\n\t}()\n\n\tconverr := func(args ...string) error {\n\t\tif len(args) > 0 {\n\t\t\treturn fmt.Errorf(\"error setting argument %q: can not convert %s to %s: %s\", path, val, dst.Type().String(), args[0])\n\t\t}\n\t\treturn fmt.Errorf(\"error setting argument %q: can not convert %s to %s\", path, val, dst.Type().String())\n\t}\n\n\tif _, isnone := val.(starlark.NoneType); isnone {\n\t\treturn nil\n\t}\n\n\tfor dst.Kind() == reflect.Ptr {\n\t\tif dst.IsNil() {\n\t\t\tdst.Set(reflect.New(dst.Type().Elem()))\n\t\t}","sourceCodeStart":610,"sourceCodeEnd":646,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/starbind/conv.go#L610-L646","documentation":"unmarshalStarlarkValueIntl converts a Starlark value into a Go value (dst) when preparing arguments for Delve API calls from Starlark. The deferred recover catches reflect panics (e.g. Set on unaddressable/wrong-kind values, nil deref) and converts them into this error including the argument path and the panic value.","triggerScenarios":"Calling a Delve API function from Starlark with an argument value whose shape forces reflect to panic during Set — e.g. assigning a struct to an incompatible field, nil map/slice target, or wrong-kind conversion.","commonSituations":"Scripts passing deeply nested values (lists of dicts) into rpc call parameters that expect specific Go types; typos in nested field paths produce non-assignable targets.","solutions":["Match the argument structure exactly to the API's Go parameter type","Convert nested values with proper types (starlark.String for string fields, etc.)","Simplify the value: pass scalars or construct via a helper struct value","Read the path in the error to find the offending nested field"],"exampleFix":"# before\napi.SetBreakpoint(t, \"file.go\", 10, bp_with_bad_struct)  # reflect panic\n# after\nbp = api.Breakpoint{}\nbp.Line = 10\napi.SetBreakpoint(t, \"file.go\", 10, bp)","handlingStrategy":"try-catch","validationCode":"# validate argument shape before the API call\nassert isinstance(arg, dict) or is_scalar(arg), \"argument must be struct-like or scalar\"","typeGuard":null,"tryCatchPattern":"try:\n    api.SomeCall(args...)\nexcept Exception as e:\n    if \"error setting argument\" in str(e) and \"panic\" in str(e).lower():\n        fail(e)  # path in message shows the offending nested field\n    else:\n        raise","preventionTips":["Mirror the Go parameter type exactly when building arguments","Build nested structs field-by-field instead of ad-hoc dicts","Read the quoted path in the error to locate the bad sub-value"],"tags":["starlark","delve","scripting","reflection"],"backgroundTag":"starlark-argument-conversion-failed","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}