{"record":{"id":"2d2c032ae1ad9bb0","repo":"d2lang/d2","slug":"not-found","errorCode":null,"errorMessage":"not found","messagePattern":"not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2oracle/edit.go","lineNumber":2480,"sourceCode":"func ReparentIDDelta(g *d2graph.Graph, boardPath []string, key, parentKey string) (string, error) {\n\tmk, err := d2parser.ParseMapKey(key)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tboardG := g\n\n\tif len(boardPath) > 0 {\n\t\t// When compiling a nested board, we can read from boardG but only write to baseBoardG\n\t\tboardG = GetBoardGraph(g, boardPath)\n\t\tif boardG == nil {\n\t\t\treturn \"\", fmt.Errorf(\"board %v not found\", boardPath)\n\t\t}\n\t}\n\n\tobj, ok := boardG.Root.HasChild(d2graph.Key(mk.Key))\n\tif !ok {\n\t\treturn \"\", errors.New(\"not found\")\n\t}\n\n\tparent := boardG.Root\n\tif parentKey != \"\" {\n\t\tmk2, err := d2parser.ParseMapKey(parentKey)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tparent, ok = boardG.Root.HasChild(d2graph.Key(mk2.Key))\n\t\tif !ok {\n\t\t\treturn \"\", errors.New(\"not found\")\n\t\t}\n\t}\n\n\tprevParent := obj.Parent\n\tobj.Parent = parent\n\tid := obj.AbsID()\n\tobj.Parent = prevParent","sourceCodeStart":2462,"sourceCodeEnd":2498,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2oracle/edit.go#L2462-L2498","documentation":"ReparentIDDelta looks up the object being reparented via boardG.Root.HasChild(d2graph.Key(mk.Key)). If the board's root has no child matching the parsed key, the operation cannot proceed and it returns the bare error 'not found'. This is a lookup failure on the object to be moved, not on the destination.","triggerScenarios":"Calling d2oracle.ReparentIDDelta with a boardPath whose board exists, but whose objKey parses to a key that does not exist as a direct/descendant child of that board's Root (typo, wrong board, object already deleted, or key belonging to a different board).","commonSituations":"Passing a key scoped to the top-level graph while boardPath points at a sub-board; reparenting an object that a previous delta already deleted; stale keys after a rename in another client.","solutions":["Verify objKey exists on the target board before calling: g.Root.HasChild(d2graph.Key(mk)) returns true.","Check that boardPath points at the board that actually contains the object; pass the correct board path.","Re-fetch the latest graph (d2lib.Compile) and rebuild the key; the object may have been renamed or deleted.","Normalize the key with d2parser.ParseMapKey and compare AbsID() against candidates to catch formatting/whitespace mismatches."],"exampleFix":"// before\ndelta, err := d2oracle.ReparentIDDelta(graph.Id, mk, \"child\", \"newParent\") // key missing: \"not found\"\n// after\nobj, ok := boardG.Root.HasChild(d2graph.Key(mk.Key))\nif !ok {\n    return fmt.Errorf(\"object %s not found on board %v\", objKey, boardPath)\n}\ndelta, err := d2oracle.ReparentIDDelta(graph.Id, mk, \"child\", \"newParent\")","handlingStrategy":"validation","validationCode":"mk, err := d2parser.ParseMapKey(objKey)\nif err != nil { return err }\nboardG, err := resolveBoard(g, boardPath)\nif err != nil { return err }\nif _, ok := boardG.Root.HasChild(d2graph.Key(mk.Key)); !ok {\n    return fmt.Errorf(\"object %q does not exist on board %v\", objKey, boardPath)\n}","typeGuard":"func objectExists(g *d2graph.Graph, boardPath string, key string) bool {\n    mk, err := d2parser.ParseMapKey(key)\n    if err != nil { return false }\n    bg, err := resolveBoard(g, boardPath)\n    if err != nil { return false }\n    _, ok := bg.Root.HasChild(d2graph.Key(mk.Key))\n    return ok\n}","tryCatchPattern":"delta, err := d2oracle.ReparentIDDelta(id, mk, objKey, parentKey)\nif err != nil {\n    if err.Error() == \"not found\" {\n        return fmt.Errorf(\"object %q not found on board %v; refresh graph and retry\", objKey, boardPath)\n    }\n    return err\n}","preventionTips":["Validate keys with Root.HasChild before reparenting","Keep boardPath consistent with where the key lives","Refresh/recompile the graph after other clients' edits","Derive keys from AbsID() instead of hardcoding"],"tags":["d2oracle","lookup-failure","reparent","graph-edit"],"backgroundTag":"object-not-found","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}