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

  1. Match the argument structure exactly to the API's Go parameter type
  2. Convert nested values with proper types (starlark.String for string fields, etc.)
  3. Simplify the value: pass scalars or construct via a helper struct value
  4. 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

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


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/fe2705108aea652a. Report an issue: GitHub.