Fix circular-import crash when a project .env is missing#585
Merged
Conversation
jesse/services/env.py validates that a project .env exists at import time and, if missing, called jh.error(). But jh.error() -> is_live() -> jesse.config -> jesse.modes.utils -> jesse.services.logger -> jesse.services.redis, and services.redis is exactly what imports env.py — so it is still mid-import. The result was a cryptic "cannot import name 'sync_publish' ... partially initialized module 'jesse.services.redis'" ImportError that completely hid the intended ".env is missing" message. Print the message directly to stderr (no heavy import chain) + os._exit(1), so the clear guidance is shown and the process exits cleanly. Behaviour with a valid .env is unchanged; full suite still green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
jesse/services/env.pyvalidates that a project.envexists at import time. When it's missing it calledjh.error(...)— butjh.error()→is_live()→jesse.config→jesse.modes.utils→jesse.services.logger→jesse.services.redis, andservices.redisis exactly what importsenv.py, so it's still mid-import. The result is a crypticcannot import name 'sync_publish' from partially initialized module 'jesse.services.redis'ImportError that completely hides the intended ".env is missing" message.(Surfaced while setting up the strategy-executor — Jesse running from a dir without a
.env.)Fix: print the message directly to stderr (no heavy import chain) +
os._exit(1). The clear guidance now shows and the process exits cleanly..envis unchanged..envdir it now prints the clear message + exits 1 (was: circular ImportError).🤖 Generated with Claude Code