Skip to content

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

UN-2427 [FIX] Resolve "unexpected keyword argument 'api_key'" in deployment execution GET (#1408)

vishnuszipstack55f1596f9d80
diff --git a/backend/api_v2/api_deployment_views.py b/backend/api_v2/api_deployment_views.py
index 61f4e4ee9..e13b211b4 100644
--- a/backend/api_v2/api_deployment_views.py
+++ b/backend/api_v2/api_deployment_views.py
@@ -17,6 +17,7 @@ from workflow_manager.workflow_v2.dto import ExecutionResponse
from api_v2.api_deployment_dto_registry import ApiDeploymentDTORegistry
from api_v2.constants import ApiExecution
from api_v2.deployment_helper import DeploymentHelper
+from api_v2.dto import DeploymentExecutionDTO
from api_v2.exceptions import NoActiveAPIKeyError
from api_v2.models import APIDeployment
from api_v2.serializers import (
@@ -49,9 +50,10 @@ class DeploymentExecution(views.APIView):
request: Request,
org_name: str,
api_name: str,
- api: APIDeployment,
- api_key: str,
+ deployment_execution_dto: DeploymentExecutionDTO,
) -> Response:
+ api: APIDeployment = deployment_execution_dto.api
+ api_key: str = deployment_execution_dto.api_key
serializer = ExecutionRequestSerializer(
data=request.data, context={"api": api, "api_key": api_key}
)
@@ -84,7 +86,11 @@ class DeploymentExecution(views.APIView):
@DeploymentHelper.validate_api_key
def get(
- self, request: Request, org_name: str, api_name: str, api: APIDeployment
+ self,
+ request: Request,
+ org_name: str,
+ api_name: str,
+ deployment_execution_dto: DeploymentExecutionDTO,
) -> Response:
serializer = ExecutionQuerySerializer(data=request.query_params)
serializer.is_valid(raise_exception=True)
diff --git a/backend/api_v2/deployment_helper.py b/backend/api_v2/deployment_helper.py
index 3851ca153..6af12cef0 100644
--- a/backend/api_v2/deployment_helper.py
+++ b/backend/api_v2/deployment_helper.py
@@ -19,6 +19,7 @@ from workflow_manager.workflow_v2.models import Workflow, WorkflowExecution
from workflow_manager.workflow_v2.workflow_helper import WorkflowHelper
from api_v2.api_key_validator import BaseAPIKeyValidator
+from api_v2.dto import DeploymentExecutionDTO
from api_v2.exceptions import (
ApiKeyCreateException,
APINotFound,
@@ -52,8 +53,11 @@ class DeploymentHelper(BaseAPIKeyValidator):
api_name = kwargs.get("api_name") or request.data.get("api_name")
api_deployment = DeploymentHelper.get_deployment_by_api_name(api_name=api_name)
DeploymentHelper.validate_api(api_deployment=api_deployment, api_key=api_key)
- kwargs["api"] = api_deployment
- kwargs["api_key"] = api_key
+
+ deployment_execution_dto = DeploymentExecutionDTO(
+ api=api_deployment, api_key=api_key
+ )
+ kwargs["deployment_execution_dto"] = deployment_execution_dto
return func(self, request, *args, **kwargs)
@staticmethod
diff --git a/backend/api_v2/dto.py b/backend/api_v2/dto.py
new file mode 100644
index 000000000..93df13e44
--- /dev/null
+++ b/backend/api_v2/dto.py
@@ -0,0 +1,11 @@
+from dataclasses import dataclass
+
+from api_v2.models import APIDeployment
+
+
+@dataclass
+class DeploymentExecutionDTO:
+ """DTO for deployment execution viewset."""
+
+ api: APIDeployment
+ api_key: str