{"record":{"id":"42b4353ee25ae8d7","repo":"go-delve/delve","slug":"wrong-number-of-arguments","errorCode":null,"errorMessage":"wrong number of arguments","messagePattern":"wrong number of arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/starbind/starlark.go","lineNumber":107,"sourceCode":"\t\targstrs := make([]string, len(args))\n\t\tfor i := range args {\n\t\t\ta, ok := args[i].(starlark.String)\n\t\t\tif !ok {\n\t\t\t\treturn nil, errors.New(\"argument of dlv_command is not a string\")\n\t\t\t}\n\t\t\targstrs[i] = string(a)\n\t\t}\n\t\terr := env.ctx.CallCommand(strings.Join(argstrs, \" \"))\n\t\tif err != nil && strings.Contains(err.Error(), \" has exited with status \") {\n\t\t\treturn env.interfaceToStarlarkValue(err), nil\n\t\t}\n\t\treturn starlark.None, decorateError(thread, err)\n\t})\n\tbuiltindoc(dlvCommandBuiltinName, \"(Command)\", \"interrupts, continues and steps through the program.\")\n\n\tenv.env[readFileBuiltinName] = starlark.NewBuiltin(readFileBuiltinName, func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {\n\t\tif len(args) != 1 {\n\t\t\treturn nil, decorateError(thread, errors.New(\"wrong number of arguments\"))\n\t\t}\n\t\tpath, ok := args[0].(starlark.String)\n\t\tif !ok {\n\t\t\treturn nil, decorateError(thread, errors.New(\"argument of read_file was not a string\"))\n\t\t}\n\t\tbuf, err := os.ReadFile(string(path))\n\t\tif err != nil {\n\t\t\treturn nil, decorateError(thread, err)\n\t\t}\n\t\treturn starlark.String(string(buf)), nil\n\t})\n\tbuiltindoc(readFileBuiltinName, \"(Path)\", \"reads a file.\")\n\n\tenv.env[appendFileBuiltinName] = starlark.NewBuiltin(appendFileBuiltinName, func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {\n\t\tif len(args) != 2 {\n\t\t\treturn nil, decorateError(thread, errors.New(\"wrong number of arguments\"))\n\t\t}\n\t\tpath, ok := args[0].(starlark.String)","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/starbind/starlark.go#L89-L125","documentation":"The read_file Starlark builtin in Delve's terminal scripting layer accepts exactly one positional argument (the file path). When a Starlark init script calls read_file with zero arguments or more than one, the builtin returns this error, decorated with the Starlark call stack via decorateError. It exists to enforce the documented '(Path)' signature before any file I/O is attempted.","triggerScenarios":"Calling read_file() with no arguments, read_file(a, b) with two or more arguments, or when extra positional arguments are accidentally passed (e.g. leftover arguments from a variable expansion) inside a Starlark init script executed by dlv.","commonSituations":"Users write ~/.dlv/init scripts or automation scripts that read config/state files; a typo like read_file(path, 0) or refactoring that leaves a second argument behind triggers this. It also appears when porting scripts from Python-style helpers that accept optional arguments.","solutions":["Call read_file with exactly one string argument: read_file(\"/path/to/file\")","If you need to combine multiple paths, build a single string first with the + operator or str() concatenation","Run `dlv help` or check the builtins listing (`help()` in the terminal) to confirm the documented signature '(Path)'"],"exampleFix":"// before (in .dlv/init Starlark script)\ncontents = read_file(\"/tmp/bps.txt\", \"r\")\n\n// after\ncontents = read_file(\"/tmp/bps.txt\")","handlingStrategy":"validation","validationCode":"// in Starlark before calling\nif len(args) != 1:\n    fail(\"read_file requires exactly one path argument\")\npath = args[0]\nif type(path) != \"string\":\n    fail(\"read_file path must be a string\")","typeGuard":"def is_str(v):\n    return type(v) == \"string\"\n\n# usage\nif is_str(p):\n    contents = read_file(p)","tryCatchPattern":null,"preventionTips":["Match the documented signature '(Path)' exactly - one string argument","Concatenate path pieces into a single string before calling","Test init scripts with `dlv --init script.init` on a trivial session first"],"tags":["starlark","scripting","argument-count"],"backgroundTag":"wrong-argument-count","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}