{"record":{"id":"c54ac0d6dc508ef5","repo":"canopy-network/canopy","slug":"iterator-not-supported-on-subtree-store","errorCode":null,"errorMessage":"iterator not supported on subtree store","messagePattern":"iterator not supported on subtree store","errorType":"error_code","errorClass":"ErrStoreGet","httpStatus":null,"severity":"error","filePath":"store/txn.go","lineNumber":366,"sourceCode":"\treturn s.reader.Get(lib.Append(s.prefix, key))\n}\n\nfunc (s *subtreeStore) Set(key, value []byte) lib.ErrorI {\n\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}","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/canopy-network/canopy/blob/ee8197d91dd410f6592cb650a94c925ee6dc8bad/store/txn.go#L348-L384","documentation":"Raised unconditionally by subtreeStore.Iterator. A subtreeStore is an in-memory overlay of pending writes over a store prefix; it has no key-ordered scan capability, so iteration is deliberately unsupported. Any caller attempting prefix/range iteration over a subtree store gets this error instead of wrong results.","triggerScenarios":"Thrown at store/txn.go:366 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Refactor the caller to iterate over the underlying full store rather than the subtree overlay.","Accumulate keys into a slice during writes if ordered traversal is needed, and iterate that instead.","Use Get for point lookups only on subtreeStore."],"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"}