{"record":{"id":"0cd4406e282271f9","repo":"go-delve/delve","slug":"too-many-arguments-0cd440","errorCode":null,"errorMessage":"too many arguments","messagePattern":"too many arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/dap/command.go","lineNumber":297,"sourceCode":"\t\t\t}\n\t\t}\n\t\targv = config.Split2PartsBySpace(argv[1])\n\t\tswitch argv[0] {\n\t\tcase \"-on\":\n\t\t\tvar regex string\n\t\t\tif len(argv) == 2 {\n\t\t\t\tregex = argv[1]\n\t\t\t}\n\t\t\tif err := s.debugger.FollowExec(true, regex); err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\tif regex != \"\" {\n\t\t\t\treturn fmt.Sprintf(\"Follow exec mode enabled with regex %q\", regex), nil\n\t\t\t}\n\t\t\treturn \"Follow exec mode enabled\", nil\n\t\tcase \"-off\":\n\t\t\tif len(argv) > 1 {\n\t\t\t\treturn \"\", errors.New(\"too many arguments\")\n\t\t\t}\n\t\t\tif err := s.debugger.FollowExec(false, \"\"); err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\treturn \"Follow exec mode disabled\", nil\n\t\tdefault:\n\t\t\treturn \"\", fmt.Errorf(\"unknown argument %q to 'target follow-exec'\", argv[0])\n\t\t}\n\tcase \"switch\": // TODO: This may cause inconsistency between debugger and frontend.\n\t\ttgrp, unlock := s.debugger.LockTargetGroup()\n\t\tdefer unlock()\n\t\tpid, err := strconv.Atoi(argv[1])\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tfound := false\n\t\tfor _, tgt := range tgrp.Targets() {\n\t\t\tif _, err = tgt.Valid(); err == nil && tgt.Pid() == pid {","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/dap/command.go#L279-L315","documentation":"The DAP `target` command's `-off` subcommand disables follow-exec mode and takes no further arguments. If extra tokens remain after `-off`, targetCmd returns this error rather than silently ignoring them.","triggerScenarios":"`target follow-exec -off something` — any argv beyond the `-off` token, e.g. a stray regex argument left from a previous `-regex` invocation.","commonSituations":"Toggle-style clients that append the old regex value when turning follow-exec off; copy-pasted command lines with trailing whitespace-separated junk; scripting that always passes both on/off and a pattern.","solutions":["Send `target follow-exec -off` with no additional arguments","Strip the regex/pattern argument when disabling follow-exec","Handle enable (`-regex <pattern>`) and disable (`-off`) as separate argument shapes in client code"],"exampleFix":"// before\n\"target follow-exec -off main.go\"\n// after\n\"target follow-exec -off\"","handlingStrategy":"validation","validationCode":"func followExecArgs(on bool, pattern string) string {\n\tif !on { return \"target follow-exec -off\" }\n\treturn \"target follow-exec -regex \" + pattern\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never append the regex when disabling follow-exec","Model -off as a zero-argument toggle","Trim trailing tokens from user input"],"tags":["dap","repl","argument-parsing"],"backgroundTag":"too-many-arguments","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}