fix: safe import for create claude session method in startup hook#1219
fix: safe import for create claude session method in startup hook#1219rushilpatel0 merged 1 commit intodevelopfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. |
| try: | ||
| from codegen.cli.commands.claude.claude_session_api import create_claude_session | ||
| except ImportError: | ||
| create_claude_session = None |
There was a problem hiding this comment.
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.
| 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.
|
Found 0 critical and 1 important issues. Please review my inline comment above. |
|
🎉 This PR is included in version 0.56.8 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Motivation
Content
Testing
Please check the following before marking your PR as ready for review