{"record":{"id":"899aa25898821ae4","repo":"canopy-network/canopy","slug":"reverse-iterator-not-supported-on-subtree-store","errorCode":null,"errorMessage":"reverse iterator not supported on subtree store","messagePattern":"reverse iterator not supported on subtree store","errorType":"error_code","errorClass":"ErrStoreGet","httpStatus":null,"severity":"error","filePath":"store/txn.go","lineNumber":370,"sourceCode":"\ts.l.Lock()\n\ts.ops[lib.MemHash(key)] = valueOp{key: key, value: value, version: s.version, op: opSet}\n\ts.l.Unlock()\n\treturn nil\n}\n\nfunc (s *subtreeStore) Delete(key []byte) lib.ErrorI {\n\ts.l.Lock()\n\ts.ops[lib.MemHash(key)] = valueOp{key: key, version: s.version, op: opDelete}\n\ts.l.Unlock()\n\treturn nil\n}\n\nfunc (s *subtreeStore) Iterator([]byte) (lib.IteratorI, lib.ErrorI) {\n\treturn nil, ErrStoreGet(fmt.Errorf(\"iterator not supported on subtree store\"))\n}\n\nfunc (s *subtreeStore) RevIterator([]byte) (lib.IteratorI, lib.ErrorI) {\n\treturn nil, ErrStoreGet(fmt.Errorf(\"reverse iterator not supported on subtree store\"))\n}\n\n// Copy creates a new Txn with the same configuration and txn as the original\nfunc (t *Txn) Copy(reader TxnReaderI, writer TxnWriterI) *Txn {\n\treturn &Txn{\n\t\treader:       reader,\n\t\twriter:       writer,\n\t\tprefix:       t.prefix,\n\t\tstate:        t.state,\n\t\tsort:         t.sort,\n\t\twriteVersion: t.writeVersion,\n\t\ttxn:          t.txn.copy(),\n\t}\n}\n\n// txn() returns a copy of the current transaction txn\nfunc (t *txn) copy() *txn {\n\tt.l.Lock()","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/canopy-network/canopy/blob/ee8197d91dd410f6592cb650a94c925ee6dc8bad/store/txn.go#L352-L388","documentation":"Raised unconditionally by subtreeStore.ReIterator for the same reason as Iterator: the subtree store is a pending-writes overlay with no reverse (descending-key) scan capability. Reverse iteration is intentionally unsupported rather than silently incorrect.","triggerScenarios":"Thrown at store/txn.go:370 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Perform reverse iteration on the underlying versioned store instead of the subtree overlay.","Collect written keys in a list and sort descending if reverse traversal of pending ops is required.","Restrict subtreeStore usage to Get/Set/Delete point operations."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ee8197d91dd410f6592cb650a94c925ee6dc8bad","analyzedAt":"2026-09-06T09:30:15.973Z","contentChangedAt":"2026-09-06T09:30:15.973Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}