fix(webhooks): JSONB-Containment statt .any() auf JSON-Spalte — behebt 158 fehlgeschlagene Outbox-Events

This commit is contained in:
Agent Zero
2026-09-14 07:55:07 +02:00
parent 36e46f60f7
commit 50d6733df6
3 changed files with 187 additions and 4 deletions
+6 -2
View File
@@ -14,7 +14,8 @@ from typing import Any
from urllib.parse import urlparse
import httpx
from sqlalchemy import select
from sqlalchemy import cast, select
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.ext.asyncio import AsyncSession
from app.core.visibility import apply_visibility_filter, check_single_entity_access
@@ -74,7 +75,10 @@ async def list_webhooks(
Webhook.tenant_id == tenant_id,
)
if event:
stmt = stmt.where(Webhook.events.any(event))
# Webhook.events is a JSONB array column (NOT a relationship):
# events @> '["<event>"]' — JSONB containment instead of the invalid
# relationship .any() call (same fix as webhook_dispatcher).
stmt = stmt.where(cast(Webhook.events, JSONB).contains([event]))
if user_id and not is_system_admin:
stmt = await apply_visibility_filter(
db, stmt, "webhook", Webhook, user_id, tenant_id, is_system_admin