go-delve/delve · error

expected normal, simple or fromg after -mode

Error message

expected normal, simple or fromg after -mode

What it means

The stack command's -mode option consumes the following token as its value. If the token after -mode is missing (end of argument list), there is no mode name to dispatch on, so parseStackArgs returns this error from within the flag-parsing loop.

Source

Thrown at pkg/terminal/command.go:2483

					return 0, fmt.Errorf("expected number after %s", name)
				}
				n, err := strconv.Atoi(args[i])
				if err != nil {
					return 0, fmt.Errorf("expected number after %s: %v", name, err)
				}
				return n, nil
			}
			switch args[i] {
			case "-full":
				r.full = true
			case "-offsets":
				r.offsets = true
			case "-defer":
				r.opts |= api.StacktraceReadDefers
			case "-mode":
				i++
				if i >= len(args) {
					return stackArgs{}, errors.New("expected normal, simple or fromg after -mode")
				}
				switch args[i] {
				case "normal":
					r.opts &^= api.StacktraceSimple
					r.opts &^= api.StacktraceG
				case "simple":
					r.opts |= api.StacktraceSimple
				case "fromg":
					r.opts |= api.StacktraceG | api.StacktraceSimple
				default:
					return stackArgs{}, errors.New("expected normal, simple or fromg after -mode")
				}
			case "-a":
				i++
				n, err := numarg("-a")
				if err != nil {
					return stackArgs{}, err
				}

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Provide the mode value: 'stack -mode normal', 'stack -mode simple', or 'stack -mode fromg'.
  2. Remove -mode entirely to use the default (normal) mode.
  3. Check 'help stack' for accepted -mode values.

Example fix

// before
(dlv) stack -mode
// after
(dlv) stack -mode simple
Defensive patterns

Strategy: validation

Validate before calling

func validateStackMode(args []string) error {
    for i, a := range args {
        if a == "-mode" && i+1 >= len(args) {
            return errors.New("-mode requires normal|simple|fromg")
        }
    }
    return nil
}

Try / catch

_, err := parseStackArgs(args)
if err != nil && strings.Contains(err.Error(), "after -mode") {
    return fmt.Errorf("-mode given without value in %v", args)
}

Prevention

When it happens

Trigger: Running 'stack -mode' with nothing after it — the loop increments i past the end so i >= len(args) — in the stack argument parser (pkg/terminal/command.go).

Common situations: Truncated command from history editing or script generation, users assuming -mode has a default value when given bare.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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