{"record":{"id":"983e2b61438e151d","repo":"cayleygraph/cayley","slug":"errnodenotexists","errorCode":"ErrNodeNotExists","errorMessage":"node does not exist","messagePattern":"node does not exist","errorType":"error_code","errorClass":"DeltaError","httpStatus":null,"severity":"error","filePath":"graph/quadwriter.go","lineNumber":86,"sourceCode":"\tQuadStore\n\tQuadWriter\n}\n\ntype IgnoreOpts struct {\n\tIgnoreDup, IgnoreMissing bool\n}\n\nfunc (h *Handle) Close() error {\n\terr := h.QuadWriter.Close()\n\th.QuadStore.Close()\n\treturn err\n}\n\nvar (\n\tErrQuadExists    = errors.New(\"quad exists\")\n\tErrQuadNotExist  = errors.New(\"quad does not exist\")\n\tErrInvalidAction = errors.New(\"invalid action\")\n\tErrNodeNotExists = errors.New(\"node does not exist\")\n)\n\n// DeltaError records an error and the delta that caused it.\ntype DeltaError struct {\n\tDelta Delta\n\tErr   error\n}\n\nfunc (e *DeltaError) Error() string {\n\tif !e.Delta.Quad.IsValid() {\n\t\treturn e.Err.Error()\n\t}\n\treturn e.Delta.Action.String() + \" \" + e.Delta.Quad.String() + \": \" + e.Err.Error()\n}\n\nfunc (e *DeltaError) Unwrap() error {\n\treturn e.Err\n}","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/quadwriter.go#L68-L104","documentation":"ErrNodeNotExists is returned by NodeRemover implementations (writer/single.go RemoveNode) when the node value to be removed does not exist in the quadstore: either the value lookup returns nil or the node has zero quads attached. No deltas are applied in that case.","triggerScenarios":"Calling RemoveNode(qs, val) for a Value that is not present in the store (lookup returns nil); calling RemoveNodeAndAllRefs/RemoveNode when total quad count for the node is 0; removing a node that was already deleted or never inserted.","commonSituations":"Cleanup jobs removing nodes by IDs from external data where the node was never imported; double-invocation of a removal routine; deleting nodes referenced by stale identifiers after a reindex or migration.","solutions":["Look the node up in the quadstore first (qs.NameOf / qs.ValueOf) and skip removal if nil","Treat the error as success for idempotent cleanup by comparing with graph.ErrNodeNotExists / errors.Is","Re-check that the node ID spelling matches the store's identifiers (case, namespace, IRI vs BNode)","If the node was deleted concurrently, re-query and continue the batch instead of aborting"],"exampleFix":"// before\nerr := graph.RemoveNodeAndAllRefs(qs, val)\n// after\nif qs.NameOf(val) != nil {\n    err = graph.RemoveNodeAndAllRefs(qs, val)\n    if err != nil && !errors.Is(err, graph.ErrNodeNotExists) {\n        return err\n    }\n}","handlingStrategy":"validation","validationCode":"if qs.NameOf(val) == nil {\n    return nil // node absent; nothing to remove\n}","typeGuard":"func nodeExists(qs graph.QuadStore, v graph.Value) bool { return v != nil && qs.NameOf(v) != nil }","tryCatchPattern":"err := graph.RemoveNodeAndAllRefs(qs, val)\nif err != nil {\n    if errors.Is(err, graph.ErrNodeNotExists) {\n        return nil // idempotent remove\n    }\n    return err\n}","preventionTips":["Resolve node identifiers through the store before removal","Make node-cleanup routines idempotent by ignoring ErrNodeNotExists","Normalize node IDs (IRI vs BNode, case) before lookup","Re-query node state instead of trusting external ID lists"],"tags":["graph","node","removal"],"backgroundTag":"entity-not-found","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}