{"record":{"id":"883b474e38d93ccd","repo":"go-delve/delve","slug":"breakpoint-name-already-exists","errorCode":null,"errorMessage":"breakpoint name already exists","messagePattern":"breakpoint name already exists","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/debugger/debugger.go","lineNumber":706,"sourceCode":"//\n// If LocExpr is specified it will be used, along with substitutePathRules,\n// to re-enable the breakpoint after it is disabled.\n//\n// If suspended is true a logical breakpoint will be created even if the\n// location can not be found, the backend will attempt to enable the\n// breakpoint every time a new plugin is loaded.\nfunc (d *Debugger) CreateBreakpoint(requestedBp *api.Breakpoint, locExpr string, substitutePathRules [][2]string, suspended bool) (*api.Breakpoint, error) {\n\td.targetMutex.Lock()\n\tdefer d.targetMutex.Unlock()\n\n\tvar (\n\t\tsetbp proc.SetBreakpoint\n\t\terr   error\n\t)\n\n\tif requestedBp.Name != \"\" {\n\t\tif d.findBreakpointByName(requestedBp.Name) != nil {\n\t\t\treturn nil, errors.New(\"breakpoint name already exists\")\n\t\t}\n\t}\n\n\tif lbp := d.target.LogicalBreakpoints[requestedBp.ID]; lbp != nil {\n\t\tabp := d.convertBreakpoint(lbp)\n\t\treturn abp, proc.BreakpointExistsError{File: lbp.File, Line: lbp.Line}\n\t}\n\n\tswitch {\n\tcase requestedBp.TraceReturn:\n\t\tif len(d.target.Targets()) != 1 {\n\t\t\treturn nil, ErrNotImplementedWithMultitarget\n\t\t}\n\t\tsetbp.PidAddrs = []proc.PidAddr{{Pid: d.target.Selected.Pid(), Addr: requestedBp.Addr}}\n\tcase len(requestedBp.File) > 0:\n\t\tfileName := requestedBp.File\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\t// Accept fileName which is case-insensitive and slash-insensitive match","sourceCodeStart":688,"sourceCodeEnd":724,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/debugger/debugger.go#L688-L724","documentation":"Breakpoint names must be unique within a debugging session. CreateBreakpoint checks via findBreakpointByName and rejects any request whose Name is already used by an existing breakpoint. This prevents ambiguity when referencing breakpoints by name (e.g. in conditions, locations, or RPC calls).","triggerScenarios":"Calling Debugger.CreateBreakpoint (RPC2 service/createBreakpoint, DAP setBreakpoints with names, or `break -name X` twice) with a non-empty requestedBp.Name that an existing logical breakpoint already holds.","commonSituations":"Re-running a script/IDE configuration that sets named breakpoints without clearing old ones; reusing a conventional name like \"main-entry\" across sessions; tools that retry breakpoint creation after a partial failure.","solutions":["Choose a different, unique name for the new breakpoint","Amend the existing breakpoint instead of creating a new one (AmendBreakpoint)","Clear the existing breakpoint first (ClearBreakpoint by ID) then recreate it with the desired name","Look up the existing breakpoint with ListBreakpoints/findBreakpointByName and reuse its ID"],"exampleFix":"// before\nbp := &api.Breakpoint{File: \"main.go\", Line: 10, Name: \"entry\"}\nd.CreateBreakpoint(bp) // second call fails: name already exists\n// after\nif d.findBreakpointByName(\"entry\") == nil {\n    d.CreateBreakpoint(bp)\n} else {\n    amend := &api.Breakpoint{ID: existing.ID, Name: \"entry\", File: \"main.go\", Line: 10}\n    d.AmendBreakpoint(amend)\n}","handlingStrategy":"validation","validationCode":"if bp.Name != \"\" && dbg.findBreakpointByName(bp.Name) != nil {\n    return fmt.Errorf(\"name %q in use; pick another or amend ID\", bp.Name)\n}","typeGuard":"func nameIsFree(dbg *debugger.Debugger, name string) bool {\n    return name == \"\" || dbg == nil // check via ListBreakpoints in client code\n}","tryCatchPattern":"_, err := dbg.CreateBreakpoint(bp)\nif err != nil && strings.Contains(err.Error(), \"breakpoint name already exists\") {\n    // reuse existing ID via AmendBreakpoint or choose a new name\n}","preventionTips":["Prefix breakpoint names with a session/feature namespace (e.g. \"mytool-entry\")","Check ListBreakpoints output before setting named breakpoints","In frontends, map logical names to IDs and use AmendBreakpoint for changes","Clear named breakpoints at session teardown"],"tags":["breakpoint","naming-conflict","debugger"],"backgroundTag":"duplicate-resource-name","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}