openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

fix(observability): skip SQLITE_FULL "database or disk is full" (Sentry TAURI-RUST-B6N)

Open CodeGhost21 opened this issue 5 months ago • 1 comments

Summary

  • Extend is_disk_full_message in src/core/observability.rs to recognize SQLite's SQLITE_FULL text ("database or disk is full"), so the disk-full classifier silences the SQLite-emitted variant the same way it already silences the OS-emitted variants.
  • Drops Sentry TAURI-RUST-B6N (issue 12541) — 3085 events / 3 users in 0.57.18..0.57.40, all from openhuman.memory_doc_ingest on Windows hosts whose disks are genuinely full.

Problem

The classifier already maps three disk-full renderings to ExpectedErrorKind::DiskFull:

  • POSIX ENOSPC — "No space left on device (os error 28)"
  • Windows ERROR_DISK_FULL — "There is not enough space on the disk. (os error 112)"
  • The io::ErrorKind debug-name shape used by the auth-profile lock annotation — "... (kind=Some(StorageFull), os_code=Some(28))" (PR #3409, Sentry TAURI-RUST-4SZ).

Production breadcrumbs for issue 12541 show hundreds of OS-level os error 112 events from the same telegram-scanner burst that ARE correctly skipped, and one SQLite-level variant "commit tx: database or disk is full" from memory_store::unified::documents.rs:155 that is NOT skipped. That last variant is what produces the Sentry group.

SQLITE_FULL (rusqlite text: "database or disk is full") has only two possible causes:

  1. Real disk-full — always the case in practice; the same event burst always carries os-error-28/112 siblings, confirming the host disk is full.
  2. A max_page_count PRAGMA cap — we set none on the memory store.

So the SQLite-emitted variant is the same condition as the OS-emitted variant, just surfaced from a different layer. The classifier-skip decision that PR #3409 made for the StorageFull debug-name shape applies identically here.

Solution

  1. Add "database or disk is full" as a fourth substring to is_disk_full_message. Anchor on the exact SQLite phrase (no looser "database … full" wildcard) so unrelated prose that mentions a full database for other reasons still reaches Sentry.
  2. Update the function doc-comment with a "fifth shape" section documenting the SQLITE_FULL rationale, the call site (memory_store::unified::documents::tx.commit() during openhuman.memory_doc_ingest), and the two-causes argument for why this is safe.
  3. Extend the positive classifies_disk_full_errors test with the production wire string "commit tx: database or disk is full".
  4. Extend the negative does_not_classify_unrelated_space_messages test with two prose-with-"database is full" cases ("upsert failed: database is full of duplicates", "user quota: database is full for this tier") to lock in that the anchor is the exact SQLite phrasing, not generic "database" + "full".

Rejected alternatives:

  • Pre-flight disk-space check before tx.commit() — racy, wasteful, and cannot fix the user's full disk; the telegram scanner already handles the failure correctly by logging a warning at src/telegram_scanner/mod.rs:255 and moving on.
  • New typed error variant in documents.rs — heavier surgery for a one-line classifier gap that mirrors a precedent (#3409) already set in this codebase.

Submission Checklist

If a section does not apply to this change, mark the item as N/A with a one-line reason. Do not delete items.

  • [x] Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy — positive case added to classifies_disk_full_errors, two negative cases added to does_not_classify_unrelated_space_messages
  • [x] Diff coverage ≥ 80% — changed lines (Vitest + cargo-llvm-cov merged via diff-cover) meet the gate enforced by .github/workflows/pr-ci.yml. The only behavioral diff (the new substring branch in is_disk_full_message) is directly covered by the new test row in classifies_disk_full_errors; the rest of the diff is doc-comment text.
  • [x] Coverage matrix updated — N/A: behaviour-only change (Sentry-side suppression of an existing unfixable user-environment error; no feature added, removed, or renamed)
  • [x] All affected feature IDs from the matrix are listed in the PR description under ## Related — N/A: behaviour-only change, no matrix rows touched
  • [x] No new external network dependencies introduced (mock backend used per Testing Strategy) — pure in-process classifier change
  • [x] Manual smoke checklist updated if this touches release-cut surfaces (docs/RELEASE-MANUAL-SMOKE.md) — N/A: does not touch any release-cut surface
  • [x] Linked issue closed via Closes #NNN in the ## Related section — N/A: Sentry-issue fix; no GitHub issue exists. Sentry issue ID called out in ## Related instead.

Impact

  • Runtime/platform: desktop only (Windows hits the production wire string; Linux/macOS already covered by the existing POSIX ENOSPC anchor). No code path other than the Sentry-emission decision is affected — the user-facing error still propagates through the telegram scanner / memory ingestion as before; the only change is that the disk-full state stops being re-reported to Sentry from the SQLite-emitted variant.
  • Performance: one extra substring check on already-classified-as-error wire strings; negligible.
  • Security / migration / compatibility: none.

Related

  • Closes: Sentry TAURI-RUST-B6N (issue 12541) — https://sentry.tinyhumans.ai/organizations/tinyhumans/issues/12541/
  • Precedent: PR #3409 (auth-profile StorageFull debug-name variant — same one-line classifier extension pattern for a different disk-full stringification)
  • Follow-up PR(s)/TODOs: none

AI Authored PR Metadata (required for Codex/Linear PRs)

Keep this section for AI-authored PRs. For human-only PRs, mark each field N/A.

Linear Issue

  • Key: N/A — Sentry-issue fix, not Linear-tracked
  • URL: N/A

Commit & Branch

  • Branch: fix/sentry-b6n-sqlite-disk-full
  • Commit SHA: dad4d8986

Validation Run

  • [x] pnpm --filter openhuman-app format:check — N/A: Rust-only change, no app/ file touched
  • [x] pnpm typecheck — N/A: Rust-only change, no TypeScript touched
  • [x] Focused tests: GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml --lib core::observability::tests:: → 152 passed, 0 failed; classifies_disk_full_errors and does_not_classify_unrelated_space_messages both green standalone
  • [x] Rust fmt/check (if changed): cargo fmt --check -- src/core/observability.rs → clean
  • [x] Tauri fmt/check (if changed): N/A — no app/src-tauri/ file touched

Validation Blocked

  • command: N/A
  • error: N/A
  • impact: N/A

Behavior Changes

  • Intended behavior change: the SQLITE_FULL Sentry-emit path is demoted to ExpectedErrorKind::DiskFull and silenced like the OS-level disk-full variants already are. No change to user-facing error propagation, retry logic, or any other code path.
  • User-visible effect: none on the affected users themselves (they still see the underlying write failure surfaced through telegram-scanner warnings as before). The change suppresses a noisy, unfixable Sentry group that we cannot act on from code.

Parity Contract

  • Legacy behavior preserved: the OS-level disk-full variants (os error 28, os error 112, StorageFull debug-name) classify identically to before this PR; the existing positive test cases for those phrasings are unchanged.
  • Guard/fallback/dispatch parity checks: the new anchor is the literal SQLite text "database or disk is full"; negative tests pin to the fact that unrelated "database is full" prose must still surface to Sentry, so this matcher cannot grow into a generic "anything mentioning a full database" silencer.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none — searched open + closed PRs for 12541, TAURI-RUST-B6N, "commit tx", "disk is full"; no existing PR addresses this Sentry group.
  • Canonical PR: this PR
  • Resolution (closed/superseded/updated): N/A — net-new

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved detection of disk-full errors by recognizing SQLite’s “database or disk is full” wording more reliably.
    • Added stricter safeguards to avoid misclassifying unrelated “database is full” and remote/back-end framed error messages.
    • Expanded coverage to ensure the correct disk-full error kind is returned for SQLite-style messages while other similar phrases are correctly ignored.

CodeGhost21 avatar Jun 14 '26 19:06 CodeGhost21

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 43e10a8f-3f99-43e2-ab48-660ff3e5500c

📥 Commits

Reviewing files that changed from the base of the PR and between dad4d898646a1d0d62eaa2e62936b41353d237b8 and 5e1dcb1a82aa3292a4cbeeb95e9a642e9e9cd1b1.

📒 Files selected for processing (1)
  • src/core/observability.rs

📝 Walkthrough

Walkthrough

is_disk_full_message gains a new SQLite-specific matcher for "database or disk is full" with trimming of trailing whitespace and punctuation. A negative guard rejects messages containing "backend returned " to prevent suppressing remote storage errors that mention the same phrase. A positive test case validates classification of "commit tx: database or disk is full", and extended negative test cases ensure unrelated "database is full" messages (duplicates, quota, capacity) and remote/backend-framed variants are not misclassified.

Changes

SQLite disk-full classification

Layer / File(s) Summary
Disk-full classifier anchor with backend guard and test coverage
src/core/observability.rs
Adds "database or disk is full" suffix matcher with "backend returned " rejection guard to is_disk_full_message; asserts ExpectedErrorKind::DiskFull for "commit tx: database or disk is full" in classifies_disk_full_errors; adds negative assertions in does_not_classify_unrelated_space_messages for unrelated quota/capacity messages and remote/backend-framed variants.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • tinyhumansai/openhuman#3409: Both PRs extend is_disk_full_message to recognize additional error-message patterns for disk-full/storage-full classification.

Poem

A rabbit refined the disk-full detection, Adding SQLite's voice to the error collection. With guards to block backend's false confessions, It sorts the real disk-full obsessions. Now storage errors find their true direction — 🐇💾

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically summarizes the main change: fixing the disk-full error classifier to recognize SQLite's SQLITE_FULL error text with the exact phrase 'database or disk is full', addressing a known Sentry issue.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Jun 14 '26 19:06 coderabbitai[bot]