{"record":{"id":"ed52e81e479d87d6","repo":"go-delve/delve","slug":"too-many-arguments-to-trace","errorCode":null,"errorMessage":"too many arguments to trace","messagePattern":"too many arguments to trace","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/command.go","lineNumber":2010,"sourceCode":"\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn created, nil\n}\n\nfunc breakpoint(t *Term, ctx callContext, args string) error {\n\t_, err := setBreakpoint(t, ctx, false, args)\n\treturn err\n}\n\nfunc tracepoint(t *Term, ctx callContext, args string) error {\n\tif ctx.Prefix == onPrefix {\n\t\tif args != \"\" {\n\t\t\treturn errors.New(\"too many arguments to trace\")\n\t\t}\n\t\tctx.Breakpoint.Tracepoint = true\n\t\treturn nil\n\t}\n\t_, err := setBreakpoint(t, ctx, true, args)\n\treturn err\n}\n\nfunc getEditorName() (string, []string, error) {\n\tvar editor string\n\tif editor = os.Getenv(\"DELVE_EDITOR\"); editor == \"\" {\n\t\tif editor = os.Getenv(\"EDITOR\"); editor == \"\" {\n\t\t\treturn \"\", nil, errors.New(\"Neither DELVE_EDITOR or EDITOR is set\")\n\t\t}\n\t}\n\n\teditorParts := strings.Fields(editor)\n\teditor = editorParts[0]","sourceCodeStart":1992,"sourceCodeEnd":2028,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/command.go#L1992-L2028","documentation":"The 'trace'/'tracepoint' terminal command in Delve is being used with a positional argument while inside an 'on <bp>' breakpoint context. In 'on' mode the command takes no arguments because it only toggles the tracepoint flag on the existing breakpoint; extra text cannot be interpreted, so Delve rejects it with this error.","triggerScenarios":"Running 'on <breakpoint-id> trace <something>' with non-empty args, i.e. typing 'trace' with any extra argument while ctx.Prefix == onPrefix in the tracepoint handler (pkg/terminal/command.go tracepoint).","commonSituations":"Users habitually appending an expression or file:line to 'trace' the way they do with plain 'break', not realizing that inside an 'on' block trace takes no target.","solutions":["Remove all arguments: use 'on <bp> trace' with nothing after 'trace'.","If you meant to create a new tracepoint at a location, drop the 'on' prefix and run 'trace <file:line>' instead.","If you wanted breakpoint variables printed on hit, use 'on <bp> print <expr>' rather than passing args to trace."],"exampleFix":"// before\n(dlv) on 1 trace main.myVar\n// after\n(dlv) on 1 trace","handlingStrategy":"validation","validationCode":"// in scripts driving the dlv terminal (batch/file mode)\nfunc validateOnTrace(cmd string) error {\n    if strings.HasPrefix(cmd, \"on \") && strings.HasSuffix(cmd, \"trace\") &&\n        len(strings.Fields(cmd)) != 3 {\n        return fmt.Errorf(\"'on <bp> trace' takes no arguments: %q\", cmd)\n    }\n    return nil\n}","typeGuard":"// Go: narrow a parsed command line before executing\nfunc isBareTrace(ctxPrefix, args string) bool {\n    return ctxPrefix == \"on\" && args == \"\"\n}","tryCatchPattern":"if err := term.Cmd.Tracepoint(ctx, args); err != nil {\n    if err.Error() == \"too many arguments to trace\" {\n        // retry with bare command\n        return term.Cmd.Tracepoint(ctx, \"\")\n    }\n    return err\n}","preventionTips":["Never append arguments to 'trace' inside 'on <bp>' blocks","Use 'trace <loc>' without the on-prefix to create a new tracepoint","Check 'help on' / 'help trace' for the no-arg form","Automate terminal scripts with argument-count validation"],"tags":["terminal","cli-usage","breakpoint"],"backgroundTag":"invalid-command-arguments","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}