Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Fix linear-related mypy type errors and make Manager.start_job async (#13189)

Rohit Malhotra222e8bd03d17
diff --git a/enterprise/integrations/github/github_manager.py b/enterprise/integrations/github/github_manager.py
index 37b03a330d..e118a5848b 100644
--- a/enterprise/integrations/github/github_manager.py
+++ b/enterprise/integrations/github/github_manager.py
@@ -318,7 +318,7 @@ class GithubManager(Manager[GithubViewType]):
logger.warning('Unsupported location')
return
- async def start_job(self, github_view: GithubViewType):
+ async def start_job(self, github_view: GithubViewType) -> None:
"""Kick off a job with openhands agent.
1. Get user credential
diff --git a/enterprise/integrations/gitlab/gitlab_manager.py b/enterprise/integrations/gitlab/gitlab_manager.py
index 9fbe5d46eb..c3641c6cc9 100644
--- a/enterprise/integrations/gitlab/gitlab_manager.py
+++ b/enterprise/integrations/gitlab/gitlab_manager.py
@@ -170,7 +170,7 @@ class GitlabManager(Manager[GitlabViewType]):
f'[GitLab] Unsupported view type: {type(gitlab_view).__name__}'
)
- async def start_job(self, gitlab_view: GitlabViewType):
+ async def start_job(self, gitlab_view: GitlabViewType) -> None:
"""
Start a job for the GitLab view.
diff --git a/enterprise/integrations/jira/jira_manager.py b/enterprise/integrations/jira/jira_manager.py
index 9223bcfa36..107acfff3d 100644
--- a/enterprise/integrations/jira/jira_manager.py
+++ b/enterprise/integrations/jira/jira_manager.py
@@ -257,7 +257,7 @@ class JiraManager(Manager[JiraViewInterface]):
return jira_user, saas_user_auth
- async def start_job(self, view: JiraViewInterface):
+ async def start_job(self, view: JiraViewInterface) -> None:
"""Start a Jira job/conversation."""
# Import here to prevent circular import
from server.conversation_callback_processor.jira_callback_processor import (
diff --git a/enterprise/integrations/jira_dc/jira_dc_manager.py b/enterprise/integrations/jira_dc/jira_dc_manager.py
index 5adc1fbc75..a5417ddb9a 100644
--- a/enterprise/integrations/jira_dc/jira_dc_manager.py
+++ b/enterprise/integrations/jira_dc/jira_dc_manager.py
@@ -353,7 +353,7 @@ class JiraDcManager(Manager[JiraDcViewInterface]):
logger.error(f'[Jira DC] Error in is_job_requested: {str(e)}')
return False
- async def start_job(self, jira_dc_view: JiraDcViewInterface):
+ async def start_job(self, jira_dc_view: JiraDcViewInterface) -> None:
"""Start a Jira DC job/conversation."""
# Import here to prevent circular import
from server.conversation_callback_processor.jira_dc_callback_processor import (
diff --git a/enterprise/integrations/linear/linear_manager.py b/enterprise/integrations/linear/linear_manager.py
index 10f1b63c52..708963ab02 100644
--- a/enterprise/integrations/linear/linear_manager.py
+++ b/enterprise/integrations/linear/linear_manager.py
@@ -343,7 +343,7 @@ class LinearManager(Manager[LinearViewInterface]):
logger.error(f'[Linear] Error in is_job_requested: {str(e)}')
return False
- async def start_job(self, linear_view: LinearViewInterface):
+ async def start_job(self, linear_view: LinearViewInterface) -> None:
"""Start a Linear job/conversation."""
# Import here to prevent circular import
from server.conversation_callback_processor.linear_callback_processor import (
diff --git a/enterprise/integrations/linear/linear_view.py b/enterprise/integrations/linear/linear_view.py
index 7f8282b705..dabe80cf60 100644
--- a/enterprise/integrations/linear/linear_view.py
+++ b/enterprise/integrations/linear/linear_view.py
@@ -152,6 +152,9 @@ class LinearExistingConversationView(LinearViewInterface):
self.conversation_id, conversation_init_data, user_id
)
+ if agent_loop_info.event_store is None:
+ raise StartingConvoException('Event store not available')
+
final_agent_observation = get_final_agent_observation(
agent_loop_info.event_store
)
diff --git a/enterprise/integrations/manager.py b/enterprise/integrations/manager.py
index 550b4ca5c1..880c252bdf 100644
--- a/enterprise/integrations/manager.py
+++ b/enterprise/integrations/manager.py
@@ -25,7 +25,7 @@ class Manager(ABC, Generic[ViewT]):
raise NotImplementedError
@abstractmethod
- def start_job(self, view: ViewT) -> None:
+ async def start_job(self, view: ViewT) -> None:
"""Kick off a job with openhands agent.
Args:
diff --git a/enterprise/integrations/slack/slack_manager.py b/enterprise/integrations/slack/slack_manager.py
index 27a892e8c4..17c57f7e6e 100644
--- a/enterprise/integrations/slack/slack_manager.py
+++ b/enterprise/integrations/slack/slack_manager.py
@@ -303,7 +303,7 @@ class SlackManager(Manager[SlackViewInterface]):
return True
- async def start_job(self, slack_view: SlackViewInterface):
+ async def start_job(self, slack_view: SlackViewInterface) -> None:
# Importing here prevents circular import
from server.conversation_callback_processor.slack_callback_processor import (
SlackCallbackProcessor,
diff --git a/enterprise/server/routes/integration/linear.py b/enterprise/server/routes/integration/linear.py
index 9d47c04b0c..2e23325398 100644
--- a/enterprise/server/routes/integration/linear.py
+++ b/enterprise/server/routes/integration/linear.py
@@ -523,6 +523,11 @@ async def get_current_workspace_link(request: Request):
try:
user_auth = cast(SaasUserAuth, await get_user_auth(request))
user_id = await user_auth.get_user_id()
+ if not user_id:
+ raise HTTPException(
+ status_code=status.HTTP_401_UNAUTHORIZED,
+ detail='User not authenticated',
+ )
user = await linear_manager.integration_store.get_user_by_active_workspace(
user_id
@@ -576,6 +581,11 @@ async def unlink_workspace(request: Request):
try:
user_auth = cast(SaasUserAuth, await get_user_auth(request))
user_id = await user_auth.get_user_id()
+ if not user_id:
+ raise HTTPException(
+ status_code=status.HTTP_401_UNAUTHORIZED,
+ detail='User not authenticated',
+ )
user = await linear_manager.integration_store.get_user_by_active_workspace(
user_id