Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
import sys
from pathlib import Path

from codegen.cli.utils.org import resolve_org_id

# Add the codegen CLI to the path so we can import from it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic error: resolve_org_id can be undefined if import fails

If the import inside the try block raises ImportError, only create_claude_session is set to None. resolve_org_id remains undefined and later usage (if org_id is None and resolve_org_id:) will raise a NameError, causing the hook to fail at runtime.

Suggested change
# Add the codegen CLI to the path so we can import from it
try:
from codegen.cli.commands.claude.claude_session_api import create_claude_session
from codegen.cli.utils.org import resolve_org_id
except ImportError:
create_claude_session = None
resolve_org_id = None

script_dir = Path(__file__).parent
codegen_cli_dir = script_dir.parent.parent.parent
sys.path.insert(0, str(codegen_cli_dir))

try:
from codegen.cli.commands.claude.claude_session_api import create_claude_session
from codegen.cli.utils.org import resolve_org_id
except ImportError:
create_claude_session = None

Expand Down
Loading