You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Terminate ChatGPT imports on cyclic mapping graphs #1888
Follow-up from the reviewed CodeRabbit deep scan (K45 C35). This ticket tracks one distinct fix; duplicate scan rows are consolidated here.
Reviewed evidence and scope
K45 (scan ID 06fd6a0a-fd93-4476-ac46-de7a52d93e7f, review A, Medium): Isolated real method probe with a one-node cyclic graph did not terminate; killed at 2 seconds. Mark mapping keys visited before expanding children, including message-less nodes. Group Cloud C35.
Source at current baseline: src/basic_memory/importers/chatgpt_importer.py:335.
C35 (scan ID 1c7da61c-b686-4666-89ff-297ce77ae58f, review D, Medium): Duplicate of Core K45 cyclic ChatGPT traversal; Cloud adapter is an important reachability/regression case.
Source at current baseline: apps/cloud/src/basic_memory_cloud/api/tenant/import_router.py:185.
Fix and validation
Terminate ChatGPT imports on cyclic mapping graphs.
Recheck current callers and supported behavior before choosing the smallest complete fix.
Add a bounded regression at the affected public or service boundary; demonstrate it fails without the fix.
Preserve legitimate inputs and tenant/project boundaries. Run focused tests plus repository static/type checks.
The scan/review establishes the code-level concern described above; it does not establish production exploitation. Conditional branches and local/tooling-only exposure must retain that scope.
Type: Bug (code defect, security-flavored: potential hang or CPU/memory exhaustion on crafted input)
Priority: Medium. This is a code-level concern from a reviewed scan. It is not an established production exploit. Exposure is limited to the importer, which is a local CLI/API import path (plus the Cloud adapter noted in C35).
Component: Importers (ChatGPT). The Cloud import router is a downstream caller. The label is none because the defect is in this repo's core code.
Complexity: Simple. It is a small change in one traversal helper plus a bounded regression test.
Confirmed in the current source
In src/basic_memory/importers/chatgpt_importer.py, the iterative traversal only adds a node to seen when node.get("message") is truthy (the seen.add sits inside the message check). A node with no message is never marked visited. If its children list points back to itself or to an ancestor, the node is pushed onto the stack again each pass and the while stack loop never terminates. That matches K45's one-node-cycle probe.
Notes for whoever picks this up
Mark node_id visited as soon as it is popped, before the message check and before expanding children. Skip it if it is already visited. That covers message-less nodes and any cycle length.
The existing seen check also guards duplicates of message nodes. Make sure legitimate DAG or shared-child inputs still yield each message once, in the same order.
Add the regression test at the importer's public boundary with a one-node cycle and a longer A→B→A cycle. Put a timeout on it so a regression fails fast instead of hanging.
Per C35, the Cloud adapter (import_router.py in basic-memory-cloud) depends on this importer. Check whether it needs its own regression test once this is fixed.
Duplicate check: I found no existing open issue for this.
Activity
claude commentedon Oct 28, 2026
Claude finished @phernandez's task in 20s —— View job
Triage
nonebecause the defect is in this repo's core code.Confirmed in the current source
In
src/basic_memory/importers/chatgpt_importer.py, the iterative traversal only adds a node toseenwhennode.get("message")is truthy (theseen.addsits inside the message check). A node with no message is never marked visited. If itschildrenlist points back to itself or to an ancestor, the node is pushed onto the stack again each pass and thewhile stackloop never terminates. That matches K45's one-node-cycle probe.Notes for whoever picks this up
node_idvisited as soon as it is popped, before the message check and before expanding children. Skip it if it is already visited. That covers message-less nodes and any cycle length.seencheck also guards duplicates of message nodes. Make sure legitimate DAG or shared-child inputs still yield each message once, in the same order.import_router.pyin basic-memory-cloud) depends on this importer. Check whether it needs its own regression test once this is fixed.Triage only. I made no code changes.
fix(core): bound ChatGPT mapping graph traversal (#1916)