Skip to content

fix: dashboard renders when doza_assist.__version__ is unimportable (issue #25)#30

Merged
DozaVisuals merged 1 commit into
mainfrom
fix/issue-25-version-fallback
May 21, 2026
Merged

fix: dashboard renders when doza_assist.__version__ is unimportable (issue #25)#30
DozaVisuals merged 1 commit into
mainfrom
fix/issue-25-version-fallback

Conversation

@DozaVisuals
Copy link
Copy Markdown
Owner

Summary

Defensive fix for issue #25. User on v3.5.3 reported ImportError: cannot import name '__version__' from 'doza_assist' despite the v3.5.3 source clearly exporting it — suggesting a stale/shadowed doza_assist package on sys.path (likely an old pip install in their venv from earlier install.sh --clean runs).

The blast radius was outsized: inject_brand is a Flask context processor, so the import crashed every page render and left Flask half-alive — which is why the user also had to manually kill the orphaned Python process before the next launch (port 5050 stuck).

This PR wraps the import in try/except. If __version__ can't be loaded, the dashboard reads it as "unknown" and the app launches, with a clear WARNING line in server.log pointing at the likely cause.

What this doesn't fix

The user still has a stale package on their machine. Diagnosing that root cause is in flight on the issue thread (asked them for the bundled file contents + a find over their venv). This PR is the safety net so a future user with a similar sys.path collision doesn't get a fully unlaunchable app.

Test plan

  • Normal install where doza_assist/__version__ is importable → dashboard shows the real version (unchanged behavior).
  • Simulate the failure: python -c "import sys; sys.modules['doza_assist'] = type(sys)('doza_assist')" before importing app → dashboard renders, version reads as "unknown", server.log shows the WARNING.
  • Port 5050 stays free across restarts (no half-alive Flask process from a crashed render).

🤖 Generated with Claude Code

…ble (issue #25)

A v3.5.3 user reported the dashboard 500-ing with
``ImportError: cannot import name '__version__' from 'doza_assist'``
despite the v3.5.3 source clearly exporting it. The likely cause is a
stale/shadowed ``doza_assist`` package somewhere on sys.path (e.g. an
old pip install in the user's venv from earlier ``install.sh --clean``
runs) that gets resolved before the bundled package.

The blast radius was outsized: ``inject_brand`` runs as a context
processor on every template render, so the import failure crashed every
page load. Flask's process didn't shut down cleanly afterwards, which
left port 5050 stuck and required the user to kill the orphaned process
before the app could launch again. Loud port-conflict error, quiet root
cause — same masking pattern as issue #25 itself.

Wrap the import in try/except so a missing or stale ``__version__`` reads
as ``'unknown'`` and the dashboard renders. A WARNING line goes to
server.log naming the likely culprit (shadowed venv install) so the
diagnostic path is obvious if a maintainer reads the log later.

This does not change the answer for the affected user (we still need to
clear the stale package to see the real version), but it removes the
"can't launch the app at all" failure mode for anyone who hits a similar
sys.path collision in the future.

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 7205df5 May 21 2026, 12:11 AM

@DozaVisuals DozaVisuals merged commit 2f76544 into main May 21, 2026
2 of 3 checks passed
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