go-delve/delve · error
error setting argument %q to %s: %v
Error message
error setting argument %q to %s: %v
What it means
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.
Source
Thrown at pkg/terminal/starbind/conv.go:628
it.cur += 2
return true
}
// unmarshalStarlarkValue unmarshals a starlark.Value 'val' into a Go variable 'dst'.
// This works similarly to encoding/json.Unmarshal and similar functions,
// but instead of getting its input from a byte buffer, it uses a
// starlark.Value.
func unmarshalStarlarkValue(val starlark.Value, dst any, path string) error {
return unmarshalStarlarkValueIntl(val, reflect.ValueOf(dst), path)
}
func unmarshalStarlarkValueIntl(val starlark.Value, dst reflect.Value, path string) (err error) {
defer func() {
// catches reflect panics
ierr := recover()
if ierr != nil {
err = fmt.Errorf("error setting argument %q to %s: %v", path, val, ierr)
}
}()
converr := func(args ...string) error {
if len(args) > 0 {
return fmt.Errorf("error setting argument %q: can not convert %s to %s: %s", path, val, dst.Type().String(), args[0])
}
return fmt.Errorf("error setting argument %q: can not convert %s to %s", path, val, dst.Type().String())
}
if _, isnone := val.(starlark.NoneType); isnone {
return nil
}
for dst.Kind() == reflect.Ptr {
if dst.IsNil() {
dst.Set(reflect.New(dst.Type().Elem()))
}View on GitHub (pinned to a23773e6c3)
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
Example fix
# before
api.SetBreakpoint(t, "file.go", 10, bp_with_bad_struct) # reflect panic
# after
bp = api.Breakpoint{}
bp.Line = 10
api.SetBreakpoint(t, "file.go", 10, bp) Defensive patterns
Strategy: try-catch
Validate before calling
# validate argument shape before the API call assert isinstance(arg, dict) or is_scalar(arg), "argument must be struct-like or scalar"
Try / catch
try:
api.SomeCall(args...)
except Exception as e:
if "error setting argument" in str(e) and "panic" in str(e).lower():
fail(e) # path in message shows the offending nested field
else:
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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
- key type not supported %T
- 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/fe2705108aea652a.
Report an issue: GitHub.