go-delve/delve · error

too many arguments

Error message

too many arguments

What it means

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.

Source

Thrown at service/dap/command.go:297

			}
		}
		argv = config.Split2PartsBySpace(argv[1])
		switch argv[0] {
		case "-on":
			var regex string
			if len(argv) == 2 {
				regex = argv[1]
			}
			if err := s.debugger.FollowExec(true, regex); err != nil {
				return "", err
			}
			if regex != "" {
				return fmt.Sprintf("Follow exec mode enabled with regex %q", regex), nil
			}
			return "Follow exec mode enabled", nil
		case "-off":
			if len(argv) > 1 {
				return "", errors.New("too many arguments")
			}
			if err := s.debugger.FollowExec(false, ""); err != nil {
				return "", err
			}
			return "Follow exec mode disabled", nil
		default:
			return "", fmt.Errorf("unknown argument %q to 'target follow-exec'", argv[0])
		}
	case "switch": // TODO: This may cause inconsistency between debugger and frontend.
		tgrp, unlock := s.debugger.LockTargetGroup()
		defer unlock()
		pid, err := strconv.Atoi(argv[1])
		if err != nil {
			return "", err
		}
		found := false
		for _, tgt := range tgrp.Targets() {
			if _, err = tgt.Valid(); err == nil && tgt.Pid() == pid {

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Send `target follow-exec -off` with no additional arguments
  2. Strip the regex/pattern argument when disabling follow-exec
  3. Handle enable (`-regex <pattern>`) and disable (`-off`) as separate argument shapes in client code

Example fix

// before
"target follow-exec -off main.go"
// after
"target follow-exec -off"
Defensive patterns

Strategy: validation

Validate before calling

func followExecArgs(on bool, pattern string) string {
	if !on { return "target follow-exec -off" }
	return "target follow-exec -regex " + pattern
}

Prevention

When it happens

Trigger: `target follow-exec -off something` — any argv beyond the `-off` token, e.g. a stray regex argument left from a previous `-regex` invocation.

Common situations: 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.

Related errors


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