Files
hermes-agent/tests/state/test_disk_full_error.py
Brooklyn Nicholson 24f346ee77 fix(gateway): fail prompt.submit when session storage hits a full disk
Disk-full / ENOSPC / SQLITE_FULL on first-message session persist used to be
swallowed as a debug log while prompt.submit still returned streaming, so the
send vanished with no error. Re-raise those failures, return a real RPC error,
and stamp session_persistence_failed turns with error so clients get a terminal
error frame.
2026-08-01 00:27:17 -05:00

31 lines
1.1 KiB
Python

"""is_disk_full_error classifies ENOSPC / SQLITE_FULL failures."""
from __future__ import annotations
import errno
import sqlite3
from hermes_state import is_disk_full_error
def test_enospc_oserror():
assert is_disk_full_error(OSError(errno.ENOSPC, "No space left on device")) is True
def test_sqlite_full_operational_error():
assert is_disk_full_error(sqlite3.OperationalError("database or disk is full")) is True
def test_string_markers():
assert is_disk_full_error("disk full: session storage could not be written") is True
assert is_disk_full_error("ENOSPC writing state.db") is True
assert is_disk_full_error("This is often a full disk — free some space") is True
def test_unrelated_errors():
assert is_disk_full_error(None) is False
assert is_disk_full_error(OSError(errno.EACCES, "Permission denied")) is False
assert is_disk_full_error(RuntimeError("network timeout")) is False
assert is_disk_full_error("session not found") is False
assert is_disk_full_error("session storage could not be written: permission denied") is False