{"record":{"id":"052b2871409c9d3d","repo":"go-delve/delve","slug":"expected-normal-simple-or-fromg-after-mode","errorCode":null,"errorMessage":"expected normal, simple or fromg after -mode","messagePattern":"expected normal, simple or fromg after -mode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/command.go","lineNumber":2483,"sourceCode":"\t\t\t\t\treturn 0, fmt.Errorf(\"expected number after %s\", name)\n\t\t\t\t}\n\t\t\t\tn, err := strconv.Atoi(args[i])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn 0, fmt.Errorf(\"expected number after %s: %v\", name, err)\n\t\t\t\t}\n\t\t\t\treturn n, nil\n\t\t\t}\n\t\t\tswitch args[i] {\n\t\t\tcase \"-full\":\n\t\t\t\tr.full = true\n\t\t\tcase \"-offsets\":\n\t\t\t\tr.offsets = true\n\t\t\tcase \"-defer\":\n\t\t\t\tr.opts |= api.StacktraceReadDefers\n\t\t\tcase \"-mode\":\n\t\t\t\ti++\n\t\t\t\tif i >= len(args) {\n\t\t\t\t\treturn stackArgs{}, errors.New(\"expected normal, simple or fromg after -mode\")\n\t\t\t\t}\n\t\t\t\tswitch args[i] {\n\t\t\t\tcase \"normal\":\n\t\t\t\t\tr.opts &^= api.StacktraceSimple\n\t\t\t\t\tr.opts &^= api.StacktraceG\n\t\t\t\tcase \"simple\":\n\t\t\t\t\tr.opts |= api.StacktraceSimple\n\t\t\t\tcase \"fromg\":\n\t\t\t\t\tr.opts |= api.StacktraceG | api.StacktraceSimple\n\t\t\t\tdefault:\n\t\t\t\t\treturn stackArgs{}, errors.New(\"expected normal, simple or fromg after -mode\")\n\t\t\t\t}\n\t\t\tcase \"-a\":\n\t\t\t\ti++\n\t\t\t\tn, err := numarg(\"-a\")\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn stackArgs{}, err\n\t\t\t\t}","sourceCodeStart":2465,"sourceCodeEnd":2501,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/command.go#L2465-L2501","documentation":"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.","triggerScenarios":"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).","commonSituations":"Truncated command from history editing or script generation, users assuming -mode has a default value when given bare.","solutions":["Provide the mode value: 'stack -mode normal', 'stack -mode simple', or 'stack -mode fromg'.","Remove -mode entirely to use the default (normal) mode.","Check 'help stack' for accepted -mode values."],"exampleFix":"// before\n(dlv) stack -mode\n// after\n(dlv) stack -mode simple","handlingStrategy":"validation","validationCode":"func validateStackMode(args []string) error {\n    for i, a := range args {\n        if a == \"-mode\" && i+1 >= len(args) {\n            return errors.New(\"-mode requires normal|simple|fromg\")\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"_, err := parseStackArgs(args)\nif err != nil && strings.Contains(err.Error(), \"after -mode\") {\n    return fmt.Errorf(\"-mode given without value in %v\", args)\n}","preventionTips":["Always supply a value after -mode","Omit -mode for default behavior","Validate generated command lines for dangling flags"],"tags":["terminal","cli-usage","stack"],"backgroundTag":"missing-required-argument","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}