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,14 +11,18 @@
import sys
from pathlib import Path

from codegen.cli.commands.claude.claude_session_api import create_claude_session
from codegen.cli.utils.org import resolve_org_id

# Add the codegen CLI to the path so we can import from it
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
except ImportError:
create_claude_session = None
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: Potential NoneType call if import fails

If the import of create_claude_session fails, it’s set to None, but later it’s called unconditionally when org_id is present. That will raise TypeError: 'NoneType' object is not callable, causing the function to fall into the broad exception handler and return an error payload instead of cleanly proceeding.

Suggested change
create_claude_session = None
# Create session via API if available
agent_run_id = None
if org_id and callable(create_claude_session):
agent_run_id = create_claude_session(session_id, org_id)

This preserves the intended "safe import" behavior and avoids unintended exceptions while still recording session data.



def main():
"""Main hook function called by Claude Code."""
Expand Down
Loading