Skip to content

fix: errorhandler no longer masks real exceptions (issue #25)#27

Merged
DozaVisuals merged 1 commit into
mainfrom
fix/issue-25-handler-masking-3.5.3
May 20, 2026
Merged

fix: errorhandler no longer masks real exceptions (issue #25)#27
DozaVisuals merged 1 commit into
mainfrom
fix/issue-25-handler-masking-3.5.3

Conversation

@DozaVisuals
Copy link
Copy Markdown
Owner

Summary

Fixes #25. The global @app.errorhandler(Exception) lazy-imported ProviderError from inside the handler — if that import ever raised, the resulting ModuleNotFoundError replaced the original exception in server.log, masking the real root cause.

  • Hoist from ai_providers import ProviderError to top-level imports. Fails loud at startup if the bundle is incomplete, instead of starting Flask and 500-ing every request with a misleading secondary error.
  • Make _handle_provider_error exception-proof — re-raises the original e if anything inside the handler ever throws.
  • Add tests/test_error_handler.py with three regression guards (JSON-400, re-raise, top-level import).
  • build_launcher.sh: post-rsync existence check for ai_providers/, doza_assist/, exporters/, templates/, static/, app.py, etc. — build aborts if any are missing. Also adds --exclude='.claude' to keep worktrees out of the DMG.
  • launcher.sh: error dialog tails 50 lines instead of 15 and prepends a "re-download the DMG" hint when server.log contains ModuleNotFoundError.
  • Bumps to 3.5.3.

Test plan

  • pytest tests/test_error_handler.py passes (3/3)
  • build_launcher.sh smoke-tests the bundled app cleanly with the hoisted import
  • Signed/notarized/stapled DMG built; Gatekeeper accepts on fresh Mac

🤖 Generated with Claude Code

The global @app.errorhandler(Exception) lazy-imported ProviderError from
inside the handler. If anything went wrong with that import — even on a
correctly bundled install — the resulting ModuleNotFoundError replaced
the original exception in server.log, leaving users with a misleading
"No module named 'ai_providers'" message instead of the root cause.

Three changes:

1. Hoist `from ai_providers import ProviderError` to top-level imports in
   app.py. The package ships in the .app bundle — there's no reason it
   was lazy. If a future build ever ships without it, the server now
   fails loudly at startup with the import error visible in server.log,
   instead of starting and 500-ing every request.

2. Make _handle_provider_error exception-proof. The ProviderError branch
   is wrapped so that if jsonify or anything else inside ever raises,
   we re-raise the ORIGINAL exception instead of substituting a new one.

3. Add tests/test_error_handler.py — three regression guards covering
   the JSON-400 path, the re-raise path, and the top-level import.

Build / launcher hardening tied to the same failure mode:

- build_launcher.sh now verifies a denylist of critical paths exist in
  the bundled APP_SRC after rsync (ai_providers/, doza_assist/, exporters/,
  templates/, static/, app.py, etc.) and aborts the build if any are
  missing. Also adds --exclude='.claude' so worktrees can't leak into the
  DMG.

- launcher.sh's show_error_dialog now tails 50 lines instead of 15 and
  prepends an actionable hint ("re-download the DMG") when server.log
  contains ModuleNotFoundError.

Bumps version to 3.5.3.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
doza-assist 0432708 May 20 2026, 02:15 PM

@DozaVisuals DozaVisuals merged commit c89568a into main May 20, 2026
2 of 3 checks passed
@DozaVisuals DozaVisuals deleted the fix/issue-25-handler-masking-3.5.3 branch May 20, 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.

Since updating to 3.5.2, app fails to load.

1 participant