{"record":{"id":"b606ed512a112555","repo":"cayleygraph/cayley","slug":"errquadnotexist","errorCode":"ErrQuadNotExist","errorMessage":"quad does not exist","messagePattern":"quad does not exist","errorType":"error_code","errorClass":"DeltaError","httpStatus":null,"severity":"error","filePath":"graph/quadwriter.go","lineNumber":84,"sourceCode":"\ntype Handle struct {\n\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 {","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/quadwriter.go#L66-L102","documentation":"ErrQuadNotExist is returned when a DELETE delta references a quad that is not present in the quadstore. Removal of a non-existent quad cannot be applied, so the transaction fails with this sentinel error (often wrapped in graph.DeltaError).","triggerScenarios":"Applying a Delete delta for a quad that was never inserted or was already removed; gaedatastore ApplyDeltas hitting the default removal path where the quad lookup fails; writers that remove before add in a rollback path where the add never succeeded.","commonSituations":"Removing a quad twice (e.g. duplicate delete in a batch); deleting based on stale query results; rebase/rollback code that deletes quads that failed to insert; tests using mis-match (mis) expectations where the missing quad is tolerated.","solutions":["Verify the quad exists (qs lookup) before appending the Delete delta","Treat as idempotent: filter the error with graph.IsQuadNotExist(err) and continue when absence is acceptable","Ensure the Add that created the quad actually succeeded before queuing its Delete (check earlier deltas' errors)","Re-fetch current quad state instead of relying on cached results that may be stale"],"exampleFix":"// before\nerr := qw.ApplyDeltas([]graph.Delta{{Action: graph.Delete, Quad: q}})\n// after\nerr := qw.ApplyDeltas([]graph.Delta{{Action: graph.Delete, Quad: q}})\nif err != nil && !graph.IsQuadNotExist(err) {\n    return err // deleting a missing quad is OK\n}","handlingStrategy":"try-catch","validationCode":"// pre-check before deleting\nif qs.QuadExists(quad) { // or lookup the quad first\n    return qw.ApplyDeltas([]graph.Delta{{Action: graph.Delete, Quad: quad}})\n}\nreturn nil","typeGuard":"func isQuadNotExist(err error) bool { return errors.Is(err, graph.ErrQuadNotExist) || graph.IsQuadNotExist(err) }","tryCatchPattern":"err := qw.ApplyDeltas(deltas)\nif err != nil {\n    if graph.IsQuadNotExist(err) {\n        // already gone: treat as success\n    } else {\n        return err\n    }\n}","preventionTips":["Only queue Delete deltas for quads confirmed to exist","Treat missing-quad deletes as idempotent no-ops","Avoid deleting based on stale cached query results","Check that the preceding Add delta succeeded before planning its delete"],"tags":["graph","quadstore","delete","delta"],"backgroundTag":"record-not-found","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}