mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 14:57:59 -05:00
Fix install-hooks CronJob failing when gitlab_webhook table doesn't exist (#12167)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -4,6 +4,8 @@ from uuid import uuid4
|
||||
|
||||
from integrations.types import GitLabResourceType
|
||||
from integrations.utils import GITLAB_WEBHOOK_URL
|
||||
from sqlalchemy import text
|
||||
from storage.database import session_maker
|
||||
from storage.gitlab_webhook import GitlabWebhook, WebhookStatus
|
||||
from storage.gitlab_webhook_store import GitlabWebhookStore
|
||||
|
||||
@@ -258,6 +260,25 @@ class VerifyWebhookStatus:
|
||||
|
||||
from integrations.gitlab.gitlab_service import SaaSGitLabService
|
||||
|
||||
# Check if the table exists before proceeding
|
||||
# This handles cases where the CronJob runs before database migrations complete
|
||||
with session_maker() as session:
|
||||
query = text("""
|
||||
SELECT EXISTS (
|
||||
SELECT FROM information_schema.tables
|
||||
WHERE table_name = 'gitlab_webhook'
|
||||
)
|
||||
""")
|
||||
result = await session.execute(query)
|
||||
table_exists = result.scalar() or False
|
||||
|
||||
if not table_exists:
|
||||
logger.info(
|
||||
'gitlab_webhook table does not exist yet, '
|
||||
'waiting for database migrations to complete'
|
||||
)
|
||||
return
|
||||
|
||||
# Get an instance of the webhook store
|
||||
webhook_store = await GitlabWebhookStore.get_instance()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user