Skip to content

Add crash reporting to the CLI (frozen-gated, filtered) + fix latent config dep#1005

Closed
abrichr wants to merge 1 commit into
mainfrom
feat/error-reporting
Closed

Add crash reporting to the CLI (frozen-gated, filtered) + fix latent config dep#1005
abrichr wants to merge 1 commit into
mainfrom
feat/error-reporting

Conversation

@abrichr

@abrichr abrichr commented Jun 25, 2026

Copy link
Copy Markdown
Member

Context

Error reporting was removed in c1efbece — "refactor: Convert to meta-package architecture (#960)", which deleted openadapt/error_reporting.py and dropped the sentry dependency. It looks like collateral damage of the meta-package split, not a deliberate decision — so this re-adds it, built for the new thin-meta-package architecture.

(The GlitchTip dashboard noise that prompted this is from old external deployments running pre-refactor versions; separately triaged/muted. This PR is about restoring crash visibility for the current app, done right.)

What

  • openadapt/error_reporting.py — initializes Sentry/GlitchTip from the CLI entry point.
    • Gated on sys.frozen (packaged build) by defaultnot the old fragile active_branch == "main" check. So dev / source / CI / headless runs never report (that source-run flooding is exactly what buried real issues, e.g. the admin123-nexus headless containers).
    • Master switch OPENADAPT_ERROR_REPORTING_ENABLED=0; force from source OPENADAPT_ERROR_REPORTING_FORCE=1.
    • before_send filter drops unactionable unsupported-environment errors (no display, wrong platform, broken native deps).
    • Never raises; no-op if sentry-sdk isn't installed.
  • config.pyOPENADAPT_ERROR_REPORTING_{ENABLED,FORCE,DSN,ENVIRONMENT} settings; DSN defaults to GlitchTip openadaptai/openadapt (3798). (DSN public key is an ingestion key, not a secret.)
  • cli.pyconfigure_error_reporting() in the main() group, covering all subcommands.
  • pyproject.toml — add sentry-sdk; also add pydantic-settings, a latent missing base depconfig.py imported it but it wasn't declared, so a clean pip install openadapt couldn't import openadapt.config (masked in CI by a transitive install).
  • tests/test_error_reporting.py — filtering + gating (8 tests, no network).

Validated

Clean-base venv install → import openadapt.config / openadapt.error_reporting OK, CLI import OK, 8 new tests pass, existing test_cli_smoke / test_import_integrity unaffected.

How to test reporting end-to-end

OPENADAPT_ERROR_REPORTING_FORCE=1 openadapt <cmd-that-errors> → event appears in GlitchTip 3798 (filtered for env noise).

Note

Supersedes #1004 (which targeted the abandoned feat/deploy branch — main had a different/removed structure). Closing that one.

🤖 Generated with Claude Code

…config dep

Error reporting was dropped in the meta-package refactor (#960). Re-add it on the
new architecture, done right:

- openadapt/error_reporting.py: init Sentry/GlitchTip from the CLI entry point.
  Gated on sys.frozen (packaged build) by default -- NOT the old, fragile
  active_branch=='main' check -- so dev/source/CI/headless runs never report
  (that source-run flooding buried real issues). Master switch + force override
  via OPENADAPT_ERROR_REPORTING_* settings. before_send drops unactionable
  unsupported-environment errors. Never raises; no-op if sentry-sdk absent.
- config.py: OPENADAPT_ERROR_REPORTING_{ENABLED,FORCE,DSN,ENVIRONMENT} settings;
  DSN defaults to GlitchTip openadaptai/openadapt (3798).
- cli.py: configure_error_reporting() in the main() group (covers subcommands).
- pyproject: add sentry-sdk; also add pydantic-settings, a latent missing base
  dep (config.py used it but it wasn't declared, so a clean install could not
  import openadapt.config).
- tests: filtering + gating (8 tests, no network).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@abrichr

abrichr commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

Triage 2026-07-17 — assessed against the post-#1012/#1013/#1014 launcher. Recommend CLOSE (superseded by the architecture, not by other code).

Rationale:

  1. The gate can never fire in the current distribution. Reporting is (correctly) gated on sys.frozen, but OpenAdapt now ships as wheel + sdist only (1.6.x releases have no frozen binaries), so the shipped artifact would never report — the PR is a no-op for users except via the FORCE env var.
  2. It cuts against the thin canonical-launcher role. Post-fix: version reads from metadata + doctor core/optional sets + pyproject description #1013/feat: make OpenAdapt the canonical openadapt-flow launcher #1014, runtime deps are deliberately just click + openadapt-flow; adding sentry-sdk (+ pydantic-settings) as hard deps of the meta-launcher expands the supply-chain surface for a wire that can't fire.
  3. The branch is 3 weeks stale against a rewritten cli.py/config.py/pyproject (CONFLICTING); a rebase would be a substantial rewrite.
  4. Where crash reporting will actually pay off is the frozen desktop bundle — the openadapt-desktop Tauri shell + PyInstaller engine sidecar. The frozen-gated + filtered design from this PR is the right template to port there when those builds go out to users.

Salvageable nugget worth a tiny separate PR if desired: openadapt/config.py on main still imports pydantic_settings, which is not a declared dependency — either declare it or make the import lazy/optional (nothing in the CLI imports openadapt.config today, so it only breaks direct imports on a clean install).

@abrichr abrichr closed this Jul 17, 2026
abrichr added a commit that referenced this pull request Jul 17, 2026
…rt (#1021)

openadapt/config.py was imported by nothing (only its own docstring
references it) and importing it crashes: pydantic_settings is not a
declared dependency of the trimmed launcher (#1013/#1014). Flagged
during triage of PR #1005.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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