{"record":{"id":"7b0caf4150cc991e","repo":"etcd-io/etcd","slug":"unexpected-serializable-in-delete","errorCode":null,"errorMessage":"unexpected serializable in delete","messagePattern":"unexpected serializable in delete","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/v3/op.go","lineNumber":285,"sourceCode":"// OpDelete returns \"delete\" operation based on given key and operation options.\nfunc OpDelete(key string, opts ...OpOption) Op {\n\t// WithPrefix and WithFromKey are not supported together\n\tif IsOptsWithPrefix(opts) && IsOptsWithFromKey(opts) {\n\t\tpanic(\"`WithPrefix` and `WithFromKey` cannot be set at the same time, choose one\")\n\t}\n\tret := Op{t: tDeleteRange, key: []byte(key)}\n\tret.applyOpts(opts)\n\tswitch {\n\tcase ret.leaseID != 0:\n\t\tpanic(\"unexpected lease in delete\")\n\tcase ret.limit != 0:\n\t\tpanic(\"unexpected limit in delete\")\n\tcase ret.rev != 0:\n\t\tpanic(\"unexpected revision in delete\")\n\tcase ret.sort != nil:\n\t\tpanic(\"unexpected sort in delete\")\n\tcase ret.serializable:\n\t\tpanic(\"unexpected serializable in delete\")\n\tcase ret.countOnly:\n\t\tpanic(\"unexpected countOnly in delete\")\n\tcase ret.minModRev != 0, ret.maxModRev != 0:\n\t\tpanic(\"unexpected mod revision filter in delete\")\n\tcase ret.minCreateRev != 0, ret.maxCreateRev != 0:\n\t\tpanic(\"unexpected create revision filter in delete\")\n\tcase ret.filterDelete, ret.filterPut:\n\t\tpanic(\"unexpected filter in delete\")\n\tcase ret.createdNotify:\n\t\tpanic(\"unexpected createdNotify in delete\")\n\t}\n\treturn ret\n}\n\n// OpPut returns \"put\" operation based on given key-value and operation options.\nfunc OpPut(key, val string, opts ...OpOption) Op {\n\tret := Op{t: tPut, key: []byte(key), val: []byte(val)}\n\tret.applyOpts(opts)","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/etcd-io/etcd/blob/f744d457f484e9f748a0700b48ef96dcf792df33/client/v3/op.go#L267-L303","documentation":"OpDelete rejects WithSerializable. Serializable reads may be served by any member without quorum confirmation; deletes are writes and always go through the raft quorum, so a 'serializable delete' has no semantics. After applyOpts sets ret.serializable, the validation switch panics with \"unexpected serializable in delete\".","triggerScenarios":"clientv3.OpDelete(k, clientv3.WithSerializable()); forwarding read-path options (built to lower read latency) into the matching invalidation Delete; config-driven option bundles applied uniformly to all ops.","commonSituations":"Read-your-writes caches that use WithSerializable on Get and reuse the same helper for eviction deletes; templates that append 'performance' options to every clientv3 call.","solutions":["Remove WithSerializable from Delete calls — every write is linearizable by definition.","Apply WithSerializable only at Get call sites (typically with WithSerializable reads for stale-tolerant dashboards)."],"exampleFix":"// before\n_, err := cli.Delete(ctx, cacheKey, clientv3.WithSerializable()) // panics\n\n// after\n_, err := cli.Delete(ctx, cacheKey)","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["WithSerializable only relaxes read consistency; writes are always linearizable.","Audit cache/eviction helpers that add 'performance' options uniformly to all ops.","Apply WithSerializable only next to Get (and WithSerializable-friendly Watch) calls."],"tags":["go","etcd","clientv3","delete","serializable","consistency","panic","invalid-option"],"backgroundTag":null,"analyzedSha":"f744d457f484e9f748a0700b48ef96dcf792df33","analyzedAt":"2026-08-15T09:39:50.079Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}