go-delve/delve · error
missing filename after -save flag
Error message
missing filename after -save flag
What it means
The 'breakpoints' (or related listing) command supports a '-save <file>' flag that writes the breakpoint list to a file. This error is returned when '-save' is the last argument so no filename follows it, detected by the `i+1 >= len(argv)` check.
Source
Thrown at pkg/terminal/command.go:1698
fmt.Fprintf(t.stdout, "%s toggled at %s\n", formatBreakpointName(bp, true), t.formatBreakpointLocation(bp))
return nil
}
func breakpoints(t *Term, ctx callContext, args string) error {
// Parse arguments
var showAll bool
var saveFile string
if args != "" {
argv := strings.Fields(args)
argsLoop:
for i, arg := range argv {
switch arg {
case "-a":
showAll = true
case "-save":
if i+1 >= len(argv) {
return errors.New("missing filename after -save flag")
}
saveFile = argv[i+1]
break argsLoop // Exit loop since we found -save and its argument
}
}
}
breakPoints, err := t.client.ListBreakpoints(showAll)
if err != nil {
return err
}
// If -save flag is provided, save breakpoints to file
if saveFile != "" {
file, err := os.Create(saveFile)
if err != nil {
return fmt.Errorf("failed to open file '%s': %w", saveFile, err)
}View on GitHub (pinned to a23773e6c3)
Solutions
- Provide a filename: 'breakpoints -save breakpoints.json'
- Quote paths containing spaces: '-save "/path/with spaces/bps.json"'
- Check 'help breakpoints' for flag ordering
Example fix
// before breakpoints -save // after breakpoints -save bps.json
Defensive patterns
Strategy: validation
Validate before calling
i := slices.Index(argv, "-save")
if i != -1 && i+1 >= len(argv) {
return errors.New("-save requires a filename argument")
} Try / catch
if err := breakpointsCmd(...); err != nil && strings.Contains(err.Error(), "missing filename after -save flag") { /* re-run with an explicit filename */ } Prevention
- Always pass a filename immediately after -save
- Quote paths containing spaces
- Validate argv completeness in scripts before invoking
When it happens
Trigger: Running 'breakpoints -save' without a trailing filename: the argsLoop sees '-save' at the last position and returns the error (pkg/terminal/command.go:1698).
Common situations: Truncated commands from shell history or scripts; forgetting that -save consumes the next token as the filename; quoting issues that swallow the filename argument.
Related errors
- address required
- argument of deferred must be a number greater than 0 (use 's
- too many arguments to restart
- Invalid next count
- too many arguments to trace
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/2efc3460420d9995.
Report an issue: GitHub.