Skip to content

tracking: warn_if_missing_table's self-heal hint isn't wired into rtk gain's read paths #3685

Open

Description

@KuSh

Found by `/code-review max` while iterating on #3206 (pre-existing gap, unrelated to that PR's `hook_decisions` feature — flagged separately rather than folded in).

`core::tracking::warn_if_missing_table` — "tracking database looks corrupted ({context}: {err}). Run `rtk init` to recreate it." — is only wired into 3 write paths (`record`, `record_parse_failure`, `record_hook_decision`) plus the 2 `discover` read paths added by #3206. None of `Tracker`'s other read methods that back plain `rtk gain` (`get_recent`, `get_summary`, `get_all_days`, `get_by_week`, `get_by_month`, `get_parse_failure_summary`) call it.

If a table is dropped/corrupted out-of-band after `user_version` is already current (the exact scenario this hint exists for), plain `rtk gain` — the single most common analytics command — fails with a raw `no such table: commands` rusqlite error instead of the friendly self-heal hint every write path (and now the `discover` reads) already give for the identical failure class.

Likely fix: route those read methods' `no such table` errors through `warn_if_missing_table` too (or a variant that returns the hint as part of the error message rather than just `eprintln!`ing, since these are read paths whose callers may want to display it differently than a write path's fire-and-forget warning).

Activity

  1. added
    bug
    good first issue
    on Aug 23, 2026
  2. pszymkowiak commented on Aug 23, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 85%

    Summary

    warn_if_missing_table's self-heal hint isn't wired into rtk gain's read paths (get_recent, get_summary, get_all_days, get_by_week, get_by_month, get_parse_failure_summary), so a corrupted tracking table surfaces a raw rusqlite error instead of the friendly 'run rtk init' hint; route these read methods through warn_if_missing_table or an equivalent that returns the hint in the error message.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/core/tracking.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibuggood first issuepriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions