{"record":{"id":"21d14c9d5ec961fd","repo":"go-delve/delve","slug":"failed-to-write-breakpoint-to-file-s-d","errorCode":null,"errorMessage":"failed to write breakpoint to file %s:%d","messagePattern":"failed to write breakpoint to file (.+?):(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/command.go","lineNumber":1747,"sourceCode":"\n\t\tfor _, bp := range breakPoints {\n\t\t\t// We don't need to store these breakpoints\n\t\t\tif bp.ID < 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Skip watchpoints as they can't be reliably restored\n\t\t\tif bp.WatchExpr != \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tvar err error\n\t\t\tif bp.Tracepoint {\n\t\t\t\t_, err = fmt.Fprintf(w, \"trace %s %s:%d\\n\", aliaser(bp), bp.File, bp.Line)\n\t\t\t} else {\n\t\t\t\t_, err = fmt.Fprintf(w, \"break %s %s:%d\\n\", aliaser(bp), bp.File, bp.Line)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to write breakpoint to file %s:%d\", bp.File, bp.Line)\n\t\t\t}\n\t\t\tif len(bp.Cond) > 0 {\n\t\t\t\t_, err = fmt.Fprintf(w, \"condition %s %s\\n\", aliaser(bp), bp.Cond)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to write condition to file %d:%s\", bp.ID, bp.Cond)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif bp.HitCond != \"\" {\n\t\t\t\tif bp.HitCondPerG {\n\t\t\t\t\t_, err = fmt.Fprintf(w, \"condition -per-g-hitcount %s %s\\n\", aliaser(bp), bp.HitCond)\n\t\t\t\t} else {\n\t\t\t\t\t_, err = fmt.Fprintf(w, \"condition -hitcount %s %s\\n\", aliaser(bp), bp.HitCond)\n\t\t\t\t}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to write hit condition to file %d:%s\", bp.ID, bp.HitCond)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif bp.Disabled {","sourceCodeStart":1729,"sourceCodeEnd":1765,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/command.go#L1729-L1765","documentation":"While saving breakpoints with `breakpoints -save`, each breakpoint is serialized as a `break`/`trace` (and `condition`) line via fmt.Fprintf into the buffered writer. If a write fails — typically a full disk, closed/errored file, or I/O error — Delve reports 'failed to write breakpoint to file <file>:<line>' identifying which breakpoint could not be persisted. Note the underlying error is not wrapped here, only the breakpoint location is reported.","triggerScenarios":"Saving many/very long breakpoints or conditions when the disk is full or the file descriptor has failed mid-write; bufio.Flush errors are deferred so the mid-loop Fprintf error path at command.go:1747 fires when the writer errors.","commonSituations":"Disk quota exceeded during a long debugging session; saving to a removable/network mount that disconnected; ulimit on file size; saving hundreds of breakpoints with very long condition expressions.","solutions":["Check free disk space (df -h) and quota, then retry `breakpoints -save`.","Verify the output file/mount is still writable and connected.","Retry the save to a different local path.","If a specific breakpoint's condition is enormous, shorten it before saving."],"exampleFix":"// before\nbreakpoints -save /mnt/usb/bps.txt   // /mnt/usb disconnected mid-write\n// failed to write breakpoint to file /app/main.go:42\n\n// after\nbreakpoints -save /home/user/bps.txt // local writable path","handlingStrategy":"fallback","validationCode":"// Check writable space before saving many breakpoints\nif fi, err := os.Statfs(dir); err == nil && fi.Bavail*uint64(fi.Bsize) < 1<<20 {\n    return errors.New(\"less than 1MB free, save may fail\")\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Execute(\"breakpoints -save \" + path); err != nil {\n    if strings.Contains(err.Error(), \"failed to write breakpoint to file\") {\n        // fall back to a different local path and retry\n        fallback := filepath.Join(os.TempDir(), \"dlv-bps.txt\")\n        cmd.Execute(\"breakpoints -save \" + fallback)\n    }\n}","preventionTips":["Ensure adequate free disk space/quota before saving large breakpoint sets.","Save to a reliable local filesystem, not removable/network mounts.","Retry the save after fixing disk issues; the error names the bp file:line to cross-check.","Keep breakpoint conditions short to reduce output size."],"tags":["terminal","filesystem","io","breakpoints","delve"],"backgroundTag":"file-write-failed","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}