Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

UN-3375 [FIX] Preserve string organization_id in CallbackTaskData chord kwargs (#1887)

ali305168363d1f
diff --git a/backend/notification_v2/internal_views.py b/backend/notification_v2/internal_views.py
index f47567dad..e352f56db 100644
--- a/backend/notification_v2/internal_views.py
+++ b/backend/notification_v2/internal_views.py
@@ -42,6 +42,8 @@ class WebhookInternalViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = NotificationSerializer
lookup_field = "id"
+ # Backward compat: remove once all workers pass X-Organization-ID.
+ skip_org_filter = True
def get_queryset(self):
"""Get notifications filtered by organization context."""
diff --git a/backend/pipeline_v2/internal_api_views.py b/backend/pipeline_v2/internal_api_views.py
index 69375a30a..5c1471d71 100644
--- a/backend/pipeline_v2/internal_api_views.py
+++ b/backend/pipeline_v2/internal_api_views.py
@@ -13,6 +13,9 @@ logger = logging.getLogger(__name__)
class PipelineInternalViewSet(ViewSet):
+ # Backward compat: remove once all workers pass X-Organization-ID.
+ skip_org_filter = True
+
def retrieve(self, request, pk=None):
logger.info(f"[PipelineInternalViewSet] Retrieving data for ID: {pk}")
diff --git a/backend/tool_instance_v2/internal_views.py b/backend/tool_instance_v2/internal_views.py
index 66f00feee..25165a973 100644
--- a/backend/tool_instance_v2/internal_views.py
+++ b/backend/tool_instance_v2/internal_views.py
@@ -23,6 +23,8 @@ class ToolExecutionInternalViewSet(viewsets.ModelViewSet):
"""Internal API for tool execution operations used by lightweight workers."""
serializer_class = ToolInstanceSerializer
+ # Backward compat: remove once all workers pass X-Organization-ID.
+ skip_org_filter = True
def get_queryset(self):
# Filter by organization context set by internal API middleware
diff --git a/backend/workflow_manager/file_execution/internal_views.py b/backend/workflow_manager/file_execution/internal_views.py
index 98bf086c3..8fed36074 100644
--- a/backend/workflow_manager/file_execution/internal_views.py
+++ b/backend/workflow_manager/file_execution/internal_views.py
@@ -29,6 +29,11 @@ class FileExecutionInternalViewSet(viewsets.ModelViewSet):
serializer_class = WorkflowFileExecutionSerializer
lookup_field = "id"
+ # Backward compat: workers may call without X-Organization-ID during
+ # rolling deployments. Safe because internal APIs require service API key
+ # and get_queryset() applies org filtering when header is present.
+ # Remove once all workers reliably pass X-Organization-ID.
+ skip_org_filter = True
def get_object(self):
"""Retrieve a single file execution by PK, bypassing get_queryset().
diff --git a/backend/workflow_manager/internal_views.py b/backend/workflow_manager/internal_views.py
index 94ecd7f76..d11ae5617 100644
--- a/backend/workflow_manager/internal_views.py
+++ b/backend/workflow_manager/internal_views.py
@@ -49,6 +49,11 @@ class WorkflowExecutionInternalViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = WorkflowExecutionSerializer
lookup_field = "id"
+ # Backward compat: workers may call without X-Organization-ID during
+ # rolling deployments. Safe because internal APIs require service API key
+ # and get_queryset() applies org filtering when header is present.
+ # Remove once all workers reliably pass X-Organization-ID.
+ skip_org_filter = True
def get_queryset(self):
"""Get workflow executions filtered by organization context."""
diff --git a/backend/workflow_manager/workflow_v2/views.py b/backend/workflow_manager/workflow_v2/views.py
index ec6fb46b7..dc428d948 100644
--- a/backend/workflow_manager/workflow_v2/views.py
+++ b/backend/workflow_manager/workflow_v2/views.py
@@ -373,6 +373,11 @@ class WorkflowExecutionInternalViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = WorkflowExecutionSerializer
lookup_field = "id"
+ # Backward compat: workers may call without X-Organization-ID during
+ # rolling deployments. Safe because internal APIs require service API key
+ # and get_queryset() applies org filtering when header is present.
+ # Remove once all workers reliably pass X-Organization-ID.
+ skip_org_filter = True
def get_queryset(self):
"""Get workflow executions filtered by organization context."""
diff --git a/backend/workflow_manager/workflow_v2/workflow_helper.py b/backend/workflow_manager/workflow_v2/workflow_helper.py
index 4dce7b793..4695f14f1 100644
--- a/backend/workflow_manager/workflow_v2/workflow_helper.py
+++ b/backend/workflow_manager/workflow_v2/workflow_helper.py
@@ -233,7 +233,10 @@ class WorkflowHelper:
result = chord(batch_tasks)(
celery_app.signature(
"process_batch_callback",
- kwargs={"execution_id": str(workflow_execution.id)},
+ kwargs={
+ "execution_id": str(workflow_execution.id),
+ "organization_id": str(organization_id),
+ },
queue=file_processing_callback_queue,
)
)
diff --git a/workers/shared/data/models.py b/workers/shared/data/models.py
index 1263e9fec..8a7147780 100644
--- a/workers/shared/data/models.py
+++ b/workers/shared/data/models.py
@@ -484,21 +484,21 @@ class CallbackTaskData:
"""Callback task data structure for worker callbacks."""
execution_id: str | UUID
- organization_id: str | UUID
+ organization_id: str
pipeline_id: str | UUID | None = None
def __post_init__(self):
- # Validate and convert to UUID or None
self.execution_id = validate_uuid(self.execution_id)
- self.organization_id = validate_uuid(self.organization_id)
+ # organization_id is a required string identifier (e.g. "org_xxx"), not a UUID
+ if not self.organization_id:
+ raise ValueError("organization_id is required for CallbackTaskData")
+ self.organization_id = str(self.organization_id)
self.pipeline_id = validate_uuid(self.pipeline_id)
def to_dict(self) -> dict[str, Any]:
data = {
"execution_id": str(self.execution_id) if self.execution_id else None,
- "organization_id": str(self.organization_id)
- if self.organization_id
- else None,
+ "organization_id": self.organization_id,
}
if self.pipeline_id:
data["pipeline_id"] = str(self.pipeline_id)