Skip to content

fix(memory): guard fetchone() against None in MemoryStore.add_fact and update_fact#23000

Closed
KhanCold wants to merge 2 commits into
NousResearch:mainfrom
KhanCold:fix/memory-fetchone-none-guard
Closed

fix(memory): guard fetchone() against None in MemoryStore.add_fact and update_fact#23000
KhanCold wants to merge 2 commits into
NousResearch:mainfrom
KhanCold:fix/memory-fetchone-none-guard

Conversation

@KhanCold

@KhanCold KhanCold commented May 10, 2026

Copy link
Copy Markdown

Closing as this duplicates existing work. Will focus on cleaner, focused PRs going forward.

KhanCold added 2 commits May 10, 2026 12:41
The LF-submit fix for thin PTYs (commit 5044e1c) regressed multiline
composition on macOS by binding c-j (LF) to submit unconditionally on
POSIX. Shift+Enter is delivered as c-j on many terminals, so it stopped
inserting newlines and submitted the message instead.

Upstream added install_shift_enter_alias() for CSI-u/modifyOtherKeys
terminals, but default macOS Terminal still sends bare LF for Shift+Enter.
This change complements upstream's approach.

Changes:
- _bind_prompt_submit_keys(): only bind 'enter'; remove unconditional
c-j binding so the caller can decide based on environment.
- In the CLI setup block, bind c-j to newline by default on POSIX local
terminals (not WSL/SSH/WT which are handled by _preserve_ctrl_enter_newline).
- When HERMES_CLI_SUBMIT_ON_LF=1 is set, bind c-j to submit instead,
opt-in for thin PTYs that deliver Enter as LF.

Adds regression tests covering:
- default POSIX: c-j inserts newline
- env HERMES_CLI_SUBMIT_ON_LF=1: c-j submits
- WSL/SSH/WT: c-j left untouched (has its own binding)

Fixes NousResearch#22908
NousResearch#22660)

Two methods in MemoryStore called .fetchone()["field"] without first
checking if fetchone() returned None, causing TypeError in race conditions.

- add_fact: after sqlite3.IntegrityError, the duplicate row may have been
deleted by a concurrent operation before the fallback SELECT executes.
  → Guard with explicit None check; raise RuntimeError for this
    impossible-but-observed state.

- update_fact: when category is not provided, a second SELECT fetches the
current category. If the row was deleted between the first SELECT and this
second one, fetchone() returns None.
  → Guard with explicit None check; return False (row no longer exists).

Fixes NousResearch#22660
@alt-glitch alt-glitch added type/bug Something isn't working comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers P3 Low — cosmetic, nice to have labels May 10, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #22660 (and #22702) — same fetchone() None guard in holographic MemoryStore. Same files changed, same fix pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants