Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

fix(telemetry): add debug logging to silent catch blocks in completion-telemetry - #1459

Merged
BYK merged 1 commit into
mainfrom
fix/completion-telemetry-silent-catches
Aug 25, 2026
Merged

BYK merged 1 commit into
mainfrom
fix/completion-telemetry-silent-catches

Conversation

@cursor

@cursor cursor Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Root Cause

Both queueCompletionTelemetry and drainCompletionTelemetry in src/lib/db/completion-telemetry.ts had catch blocks that silently swallowed errors without any logging. Per AGENTS.md, every catch block must either re-throw, log with log.debug() or log.warn(), or return a fallback value with a log.debug() call explaining the suppression.

Reproduction

  1. Corrupt or lock the CLI database
  2. Run any shell completion (sentry __complete ...)
  3. The telemetry queue write fails silently — no diagnostic output even with --verbose
  4. Similarly, drainCompletionTelemetry on the next normal CLI run swallows the error

Fix

  • Import logger and create a tagged logger (completion-telemetry)
  • Add log.debug() calls to both catch blocks so failures are visible with --verbose
  • Preserve the best-effort behavior (still catch + return fallback), just surface the error for diagnostics
Open in Web View Automation 

…n-telemetry

Both queueCompletionTelemetry and drainCompletionTelemetry had catch
blocks that silently swallowed errors without any logging. Per AGENTS.md,
every catch block must log with at least log.debug() for diagnostic
visibility. When the database is corrupted or locked, these errors
vanished silently, making debugging impossible.

Add logger import and log.debug() calls to both catch blocks so failures
are visible with --verbose.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
@vercel

vercel Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cli Ready Ready Preview Aug 24, 2026 12:10pm

Request Review

@BYK
BYK marked this pull request as ready for review August 25, 2026 08:50
@BYK
BYK merged commit 00adfbd into main Aug 25, 2026
31 checks passed
@BYK
BYK deleted the fix/completion-telemetry-silent-catches branch August 25, 2026 09:27
jared-outpost Bot added a commit that referenced this pull request Aug 25, 2026
## What

Makes error-handling enforcement systemic, per #1470. The repo already
had `check:errors` (`packages/cli/script/check-error-patterns.ts`) wired
into CI, but its silent-catch scan was **advisory only** — it warned and
never failed. That is exactly how drifts like #1459 and #1460 slipped
through.

## How

Convert the silent-catch scan into an enforcing **ratchet**, following
the existing `check-env-coverage.ts` allowlist precedent:

- Grandfather the current backlog (169 silent catches across 84 files)
into a committed baseline, `script/silent-catch-baseline.json`, keyed by
file → count.
- A **new** silent catch (a file exceeding its baseline count, or a file
not in the baseline at all) now **fails CI**.
- Removing silent catches **without** lowering the baseline also fails,
so the baseline stays honest and can only ratchet down.
- `pnpm run check:errors -- --update` regenerates the baseline after an
intentional change.
- Refactored the script to export its detectors and baseline logic so
they're unit-testable; the standalone CLI behavior is unchanged.
- Updated `packages/cli/AGENTS.md` to document the ratchet (replacing
the old "advisory / SENTRY_STRICT_SILENT_CATCH" note).

## Tests

- New `test/script/check-error-patterns.test.ts`: unit tests for
`findSilentCatches`, `findContextErrorNewlines`, `findAdHocTryPatterns`,
`countByFile`, and `compareToBaseline` (regression + stale-baseline
directions), plus a subprocess test asserting the current tree passes
against the committed baseline.
- `pnpm run check:errors` passes; `vitest run
test/script/check-error-patterns.test.ts` → 17 passing; biome + tsc
clean on the changed files.

Closes #1470

<!--
Plan: check:errors already existed and ran in CI
(.github/workflows/ci.yml) but silent-catch was advisory (169-item
backlog), so new drift was invisible to CI. Fix = ratchet baseline (same
pattern as check-env-coverage.ts INTERNAL_ENV_VARS allowlist).
Refactored check-error-patterns.ts to export pure detectors
(findSilentCatches/findContextErrorNewlines/findAdHocTryPatterns) +
scanFiles/countByFile/compareToBaseline; main() gated behind
direct-invocation check so tests can import. Baseline committed at
script/silent-catch-baseline.json (169 catches / 84 files). --update
flag regenerates it. New silent catch OR stale (shrunk) baseline both
fail CI. CI check count: ci.yml runs check:errors in the same job as
check:deps/check:patches/check:stale-refs.
-->

Co-authored-by: jared-outpost[bot] <jared-outpost[bot]@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — 95cdfc5e Deployed Aug 24, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants