{"record":{"id":"d2822097c99bb081","repo":"go-delve/delve","slug":"breakpoint-already-exists","errorCode":null,"errorMessage":"breakpoint already exists","messagePattern":"breakpoint already exists","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/dap/server.go","lineNumber":1734,"sourceCode":"\t// createdBps is a set of breakpoint names that have been added\n\t// during this request. This is used to catch duplicate set\n\t// breakpoints requests and to track which breakpoints need to\n\t// be deleted.\n\tcreatedBps := make(map[string]struct{}, len(existingBps))\n\n\tbreakpoints := make([]dap.Breakpoint, totalBps)\n\t// Amend existing breakpoints.\n\tfor i := range totalBps {\n\t\twant := metadataFunc(i)\n\t\tgot, ok := existingBps[want.name]\n\t\tif got == nil || !ok {\n\t\t\t// Skip if the breakpoint does not already exist.\n\t\t\tcontinue\n\t\t}\n\n\t\tvar err error\n\t\tif _, ok := createdBps[want.name]; ok {\n\t\t\terr = errors.New(\"breakpoint already exists\")\n\t\t} else {\n\t\t\tgot.Disabled = false\n\t\t\tgot.Cond = want.condition\n\t\t\tgot.HitCond = want.hitCondition\n\t\t\terr = setLogMessage(got, want.logMessage)\n\t\t\tif err == nil {\n\t\t\t\terr = s.debugger.AmendBreakpoint(got)\n\t\t\t}\n\t\t}\n\t\tcreatedBps[want.name] = struct{}{}\n\t\ts.updateBreakpointsResponse(breakpoints, i, err, got)\n\t}\n\n\t// Clear breakpoints.\n\t// Any breakpoint that existed before this request but was not amended must be deleted.\n\ts.clearBreakpoints(existingBps, createdBps)\n\n\t// Check if the plugin package is present or follow-exec is enabled.","sourceCodeStart":1716,"sourceCodeEnd":1752,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/dap/server.go#L1716-L1752","documentation":"When handling setBreakpoints for named/function breakpoints that already exist, the session deduplicates by breakpoint name. If a requested breakpoint name is already present in createdBps (previously created in this same request cycle), it errors with 'breakpoint already exists' instead of creating a duplicate. This protects DAP clients from ambiguous duplicate breakpoint entries.","triggerScenarios":"A setBreakpoints request whose list contains two entries resolving to the same breakpoint name (e.g. 'main.foo:12' twice); a second setBreakpoints request for the same function location while the previous one's breakpoints are being reused rather than cleared.","commonSituations":"Client UI sending both a function breakpoint and a file:line breakpoint that resolve to the same name; request lists built programmatically with duplicates; stale client state re-sending already-created breakpoints within one update batch.","solutions":["Deduplicate the requested breakpoint list on the client before sending setBreakpoints (set of names)","Remove the conflicting breakpoint (via removeBreakpoint or clearing the list) before re-adding it","Ensure one breakpoint kind per name: do not send both a function breakpoint and an equivalent file:line breakpoint with the same name","Update the DAP client to replace breakpoints by name rather than append"],"exampleFix":"// before: duplicate names in request\nbreakpoints: [{name: 'main.foo:12'}, {name: 'main.foo:12'}]\n// after: dedupe client-side\nunique := map[string]bool{}\nfor _, bp := range reqs { if !unique[bp.name] { unique[bp.name] = true; out = append(out, bp) } }","handlingStrategy":"validation","validationCode":"// dedupe requested breakpoints by name before setBreakpoints\nseen := map[string]bool{}\nfor _, bp := range req.Breakpoints {\n    if seen[bp.Name] { continue }\n    seen[bp.Name] = true\n    out = append(out, bp)\n}","typeGuard":null,"tryCatchPattern":"if err.Error() == \"breakpoint already exists\" {\n    // remove the existing breakpoint, then re-issue the request once\n}","preventionTips":["Send one breakpoint per unique name/location in each request","Do not mix function and file:line breakpoints that resolve to the same name","Replace the whole breakpoint set per source file as DAP intends, rather than appending"],"tags":["dap","breakpoints","go"],"backgroundTag":"breakpoint-already-exists","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}