Skip to content

fix(cli/purge/scopes): surface DB prepare failures in runStaleCasks#289

Merged
indaco merged 1 commit intomainfrom
fix/cli-purge-scopes-surface-db-prepare-failures
May 7, 2026
Merged

fix(cli/purge/scopes): surface DB prepare failures in runStaleCasks#289
indaco merged 1 commit intomainfrom
fix/cli-purge-scopes-surface-db-prepare-failures

Conversation

@indaco
Copy link
Copy Markdown
Owner

@indaco indaco commented May 7, 2026

Description

A consistent SQLite prepare failure inside purge --stale-casks (schema drift, lock held, partially corrupted DB) used to empty the candidate set silently - the JSON wire output then read identically to a clean "no stale casks" run. This restores the loud-error contract that --store-orphans and --unused-deps already follow:

  • A real prepare failure now sets status = "err" with error_kind = "db_prepare" and writes a stderr line, so JSON consumers can distinguish "nothing to do" from "every probe failed".
  • A bare DB file with no schema yet self-heals via initSchema, matching the sibling scopes, so a freshly-installed prefix is no longer reported as a fault.
  • Per-entry bind failures stay best-effort skips but warn instead of dropping silently.

Related Issue

  • None

Notes for Reviewers

  • None

Hoist the cask lookup out of both per-entry loops so a real prepare
failure routes through the loud err_kind path instead of silently
emptying the candidate set, and self-heal a missing schema via
initSchema to match runStoreOrphans / runUnusedDeps.
@indaco indaco merged commit 9c39f2b into main May 7, 2026
3 checks passed
@indaco indaco deleted the fix/cli-purge-scopes-surface-db-prepare-failures branch May 7, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant