go-delve/delve · error
argument of dlv_command is not a string
Error message
argument of dlv_command is not a string
What it means
The dlv_command Starlark builtin executes a Delve CLI command. It requires every argument to be a starlark.String; if any positional argument is another Starlark type (int, list, None, etc.) it returns this error rather than coercing, so command text is always built from real strings.
Solutions
- Convert arguments with str() before calling: `dlv_command("break main.go:" + str(line))`.
- Pass a single pre-joined string: `dlv_command(" ".join(args))` after mapping every element to str.
- Inspect argument types in the script (type(x) == "string") before invoking dlv_command.
Example fix
// before
line = 42
dlv_command("break main.go:", line) # error
// after
line = 42
dlv_command("break main.go:" + str(line)) Defensive patterns
Strategy: type-guard
Validate before calling
def is_string(v):
return type(v) == "string" Type guard
def is_string(v):
return type(v) == "string" Try / catch
try:
dlv_command(arg)
except Exception as e:
if "not a string" in str(e):
dlv_command(str(arg))
else:
raise Prevention
- Always str()-convert non-string values before dlv_command
- Join argument lists yourself with " ".join(map(str, args))
- Never pass lists, ints, or None directly to dlv_command
When it happens
Trigger: Calling `dlv_command(123)`, `dlv_command(["break", "main.go:1"])`, or passing a non-string variable produced by a script (e.g. an int line number) directly to dlv_command.
Common situations: Scripts assembling commands with numeric line numbers or values returned from other dlv builtins; forgetting str() conversion; passing a list expecting the builtin to splat it.
Related errors
- argument of read_file was not a string
- first argument of append_file was not a string
- first argument of write_file was not a string
- can not assign big integer to %T.
- can not assign to %T.
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/81f0249c9b836a92.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/terminal/starbind/starlark.go:93
// Make the "time" module available to Starlark scripts.
starlark.Universe["time"] = startime.Module
var doc map[string]string
env.env, doc = env.starlarkPredeclare()
builtindoc := func(name, args, descr string) {
doc[name] = name + args + "\n\n" + name + " " + descr
}
env.env[dlvCommandBuiltinName] = starlark.NewBuiltin(dlvCommandBuiltinName, func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
if err := isCancelled(thread); err != nil {
return starlark.None, err
}
argstrs := make([]string, len(args))
for i := range args {
a, ok := args[i].(starlark.String)
if !ok {
return nil, errors.New("argument of dlv_command is not a string")
}
argstrs[i] = string(a)
}
err := env.ctx.CallCommand(strings.Join(argstrs, " "))
if err != nil && strings.Contains(err.Error(), " has exited with status ") {
return env.interfaceToStarlarkValue(err), nil
}
return starlark.None, decorateError(thread, err)
})
builtindoc(dlvCommandBuiltinName, "(Command)", "interrupts, continues and steps through the program.")
env.env[readFileBuiltinName] = starlark.NewBuiltin(readFileBuiltinName, func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
if len(args) != 1 {
return nil, decorateError(thread, errors.New("wrong number of arguments"))
}
path, ok := args[0].(starlark.String)
if !ok {
return nil, decorateError(thread, errors.New("argument of read_file was not a string"))View on GitHub (pinned to a23773e6c3)