Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions integrations/azure_devops/azure_devops_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ async def create_new_conversation(
if isinstance(task._startup_error, DailySandboxLimitReached):
raise task._startup_error
logger.error(
f'[Azure DevOps] Failed to start V1 conversation: {task.detail}'
'[Azure DevOps] Failed to start V1 conversation',
extra={'detail': task.detail},
)
raise RuntimeError(
f'Failed to start V1 conversation: {task.detail}'
Expand Down Expand Up @@ -461,8 +462,9 @@ async def create_azure_devops_view_from_payload(
repo = _select_project_repo(repos, project_name)
if repo is None:
logger.warning(
f'[Azure DevOps] Could not unambiguously resolve a repository '
f'for work item in project {org}/{project_name}; skipping.'
'[Azure DevOps] Could not unambiguously resolve a repository '
'for work item in project; skipping.',
extra={'org': org, 'project_name': project_name},
)
return None
repo_name = repo.get('name') or ''
Expand Down
84 changes: 59 additions & 25 deletions integrations/jira_dc/jira_dc_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ async def authenticate_user(
)
if not keycloak_user_id:
logger.warning(
f'[Jira DC] No Keycloak user found for email: {user_email}'
'[Jira DC] No Keycloak user found for email',
extra={'user_email': user_email},
)
return None, None

Expand All @@ -203,7 +204,8 @@ async def authenticate_user(

if not jira_dc_user:
logger.warning(
f'[Jira DC] No active Jira DC user found for {user_email} in workspace {workspace_id}'
'[Jira DC] No active Jira DC user found in workspace',
extra={'user_email': user_email, 'workspace_id': workspace_id},
)
return None, None

Expand Down Expand Up @@ -324,7 +326,10 @@ async def validate_request_context(
return False, None, None, None

if workspace.status != 'active':
logger.warning(f'[Jira DC] Workspace {workspace.id} is not active')
logger.warning(
'[Jira DC] Webhook workspace is not active',
extra={'workspace_id': workspace.id},
)
return False, None, None, None

webhook_secret = self.token_manager.decrypt_text(workspace.webhook_secret)
Expand Down Expand Up @@ -430,7 +435,8 @@ async def receive_message(self, message: Message):
)
if not workspace:
logger.warning(
f'[Jira DC] No workspace found for email domain: {job_context.user_email}'
'[Jira DC] No workspace found for email domain',
extra={'user_email': job_context.user_email},
)
await self._send_error_comment(
job_context,
Expand All @@ -455,7 +461,10 @@ async def receive_message(self, message: Message):
return

if workspace.status != 'active':
logger.warning(f'[Jira DC] Workspace {workspace.id} is not active')
logger.warning(
'[Jira DC] Job workspace is not active',
extra={'workspace_id': workspace.id},
)
await self._send_error_comment(
job_context,
'Jira DC integration is not active for your workspace.',
Expand All @@ -469,7 +478,8 @@ async def receive_message(self, message: Message):
)
if not jira_dc_user or not saas_user_auth:
logger.warning(
f'[Jira DC] User authentication failed for {job_context.user_email}'
'[Jira DC] User authentication failed',
extra={'user_email': job_context.user_email},
)
# Distinguish "no OpenHands account" from "account exists but not linked
# to this workspace" so the reply is actionable (mirrors GitHub/BBDC).
Expand Down Expand Up @@ -617,8 +627,11 @@ async def start_job(self, jira_dc_view: JiraDcViewInterface) -> None:
try:
user_info: JiraDcUser = jira_dc_view.jira_dc_user
logger.info(
f'[Jira DC] Starting job for user {user_info.keycloak_user_id} '
f'issue {jira_dc_view.job_context.issue_key}',
'[Jira DC] Starting job',
extra={
'user_id': user_info.keycloak_user_id,
'issue_key': jira_dc_view.job_context.issue_key,
},
)

# Create conversation using V1 app conversation system
Expand All @@ -628,7 +641,11 @@ async def start_job(self, jira_dc_view: JiraDcViewInterface) -> None:
)

logger.info(
f'[Jira DC] Created/Updated conversation {conversation_id} for issue {jira_dc_view.job_context.issue_key}'
'[Jira DC] Created/Updated conversation for issue',
extra={
'conversation_id': conversation_id,
'issue_key': jira_dc_view.job_context.issue_key,
},
)

# Send initial response
Expand All @@ -638,19 +655,19 @@ async def start_job(self, jira_dc_view: JiraDcViewInterface) -> None:
msg_info = get_usage_limit_message()

except MissingSettingsError as e:
logger.warning(f'[Jira DC] Missing settings error: {str(e)}')
logger.warning('[Jira DC] Missing settings error', exc_info=True)
msg_info = f'Please re-login into [OpenHands Cloud]({HOST_URL}) before starting a job.'

except LLMAuthenticationError as e:
logger.warning(f'[Jira DC] LLM authentication error: {str(e)}')
logger.warning('[Jira DC] LLM authentication error', exc_info=True)
msg_info = f'Please set a valid LLM API key in [OpenHands Cloud]({HOST_URL}) before starting a job.'

except SessionExpiredError as e:
logger.warning(f'[Jira DC] Session expired: {str(e)}')
logger.warning('[Jira DC] Session expired', exc_info=True)
msg_info = get_session_expired_message()

except JiraDcUserTokenError as e:
logger.warning(f'[Jira DC] User token unavailable: {str(e)}')
logger.warning('[Jira DC] User token unavailable', exc_info=True)
msg_info = get_jira_dc_relink_message(jira_dc_view.job_context.display_name)

except Exception:
Expand Down Expand Up @@ -713,7 +730,7 @@ async def _resolve_service_account_mentions(self, payload: dict) -> set[str] | N
self._svc_mentions_cache[workspace.id] = ids
return ids or None
except Exception as e:
logger.warning(f'[Jira DC] Could not resolve bot mentions: {str(e)}')
logger.warning('[Jira DC] Could not resolve bot mentions', exc_info=True)
return None

async def _fetch_service_account_identity(
Expand Down Expand Up @@ -811,9 +828,10 @@ async def get_issue_comments(
raw_comments = response.json().get('comments', [])
except Exception as e:
logger.warning(
f'[Jira DC] Failed to fetch comment thread for '
f'{job_context.issue_key} (non-fatal, continuing without '
f'history): {str(e)}'
'[Jira DC] Failed to fetch comment thread '
'(non-fatal, continuing without history)',
extra={'issue_key': job_context.issue_key},
exc_info=True,
)
return []

Expand All @@ -839,7 +857,7 @@ async def get_issue_comments(
)
)
except Exception as e:
logger.debug(f'[Jira DC] Skipping unparseable comment: {str(e)}')
logger.debug('[Jira DC] Skipping unparseable comment', exc_info=True)
continue
return comments

Expand Down Expand Up @@ -911,11 +929,16 @@ async def _add_acknowledgement_reaction(
svc_acc_api_key=service_account.api_key,
)
logger.info(
f'[Jira DC] Reacted to comment {job_context.comment_id} on issue {job_context.issue_key}'
'[Jira DC] Reacted to comment',
extra={
'comment_id': job_context.comment_id,
'issue_key': job_context.issue_key,
},
)
except Exception as e:
logger.warning(
f'[Jira DC] Failed to add acknowledgement reaction (non-fatal): {str(e)}'
'[Jira DC] Failed to add acknowledgement reaction (non-fatal)',
exc_info=True,
)

async def register_webhook(
Expand Down Expand Up @@ -973,15 +996,21 @@ async def register_webhook(
json={**payload, 'id': webhook_id},
)
response.raise_for_status()
logger.info(f'[Jira DC] Updated webhook {webhook_id} -> {events_url}')
logger.info(
'[Jira DC] Updated webhook',
extra={'webhook_id': webhook_id, 'events_url': events_url},
)
return webhook_id

response = await client.post(
collection_url, headers=headers, json={**payload, 'id': None}
)
response.raise_for_status()
webhook_id = response.json().get('id')
logger.info(f'[Jira DC] Created webhook {webhook_id} -> {events_url}')
logger.info(
'[Jira DC] Created webhook',
extra={'webhook_id': webhook_id, 'events_url': events_url},
)
return webhook_id

async def delete_webhook(
Expand Down Expand Up @@ -1020,7 +1049,8 @@ async def delete_webhook(
)
if not existing:
logger.info(
f'[Jira DC] No webhook found for {events_url}; nothing to delete'
'[Jira DC] No webhook found; nothing to delete',
extra={'events_url': events_url},
)
return False

Expand All @@ -1029,7 +1059,10 @@ async def delete_webhook(
f'{collection_url}/{webhook_id}', headers=headers
)
response.raise_for_status()
logger.info(f'[Jira DC] Deleted webhook {webhook_id} -> {events_url}')
logger.info(
'[Jira DC] Deleted webhook',
extra={'webhook_id': webhook_id, 'events_url': events_url},
)
return True

async def _send_error_comment(
Expand Down Expand Up @@ -1080,7 +1113,8 @@ async def _send_inaccessible_repos_comment(
)

logger.info(
f'[Jira DC] Sent inaccessible repositories comment for issue {jira_dc_view.job_context.issue_key}'
'[Jira DC] Sent inaccessible repositories comment for issue',
extra={'issue_key': jira_dc_view.job_context.issue_key},
)

except Exception:
Expand Down
Loading
Loading