go-delve/delve · error

error setting argument %q: can not convert %s to %s

Error message

error setting argument %q: can not convert %s to %s

What it means

Same converr helper as [727] but without a detail argument: a generic report that value val (of its Starlark type) cannot be converted to dst's Go type. Thrown whenever unmarshalStarlarkValueIntl hits a type case it cannot handle for the destination kind.

Source

Thrown at pkg/terminal/starbind/conv.go:636

// 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()))
		}
		dst = dst.Elem()
	}

	switch val := val.(type) {
	case starlark.Bool:
		dst.SetBool(bool(val))
	case starlark.Int:
		switch dst.Kind() {

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Check argument order against the API function signature
  2. Convert values to the expected Starlark type before calling (int()/float()/str()/bool())
  3. Replace None/list/dict arguments with properly constructed struct values
  4. Consult the generated API bindings to see the target Go type

Example fix

# before
api.CreateBreakpoint(bp, None)   # None where int tid expected
# after
api.CreateBreakpoint(bp, 0)      # pass a concrete typed value
Defensive patterns

Strategy: validation

Validate before calling

assert val is not None, "None not allowed for typed argument"
assert not isinstance(val, (list, dict)) or dst_allows_composite, "composite into scalar parameter"

Type guard

def is_none(v):
    return v is None  # starlark.NoneType maps to Go nil targets only

Try / catch

try:
    api.SomeCall(val)
except Exception as e:
    if "can not convert" in str(e):
        fail("bad argument type; check signature order and convert explicitly")
    else:
        raise

Prevention

When it happens

Trigger: Any Delve API call from Starlark with an argument whose Starlark type has no registered conversion to the destination Go kind — e.g. passing None where a struct is required, a list into a scalar, or a function value as an argument.

Common situations: Scripts calling typed API entry points with positional arguments in the wrong order so values land in wrong-typed parameters.

Related errors


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