Skip to content

Automate browser based workflows with AI

fix(SKY-11536): gate WORKFLOW_TAGGING on shared workflow-tag filter endpoints (#6896)

Aaron Perez0e2bfbb2fa7b
diff --git a/skyvern/forge/sdk/routes/agent_protocol.py b/skyvern/forge/sdk/routes/agent_protocol.py
index 33a002237..326fd7ff9 100644
--- a/skyvern/forge/sdk/routes/agent_protocol.py
+++ b/skyvern/forge/sdk/routes/agent_protocol.py
@@ -4242,6 +4242,12 @@ async def get_workflows(
else:
workflow_tags.append((tag_key, tag_value))
+ if workflow_tags and not await app.AGENT_FUNCTION.is_workflow_tagging_enabled(current_org.organization_id):
+ raise HTTPException(
+ status_code=http_status.HTTP_403_FORBIDDEN,
+ detail="Workflow tagging is not enabled for this organization.",
+ )
+
if template and workflow_tags:
# Templates are global; tags are org-scoped, so the two can't combine.
raise HTTPException(
diff --git a/tests/unit/test_tag_endpoints.py b/tests/unit/test_tag_endpoints.py
index cc815ea94..b950d63bd 100644
--- a/tests/unit/test_tag_endpoints.py
+++ b/tests/unit/test_tag_endpoints.py
@@ -319,6 +319,33 @@ def test_tagging_gate_returns_403_when_disabled(client: TestClient) -> None:
)
+# ----------------------------- GET /workflows tag-filter gate ------------------------
+
+
+def test_get_workflows_with_tag_filter_returns_403_when_disabled(client: TestClient) -> None:
+ from skyvern.forge.sdk.routes import agent_protocol as ap
+
+ ap.app.WORKFLOW_SERVICE.get_workflows_by_organization_id = AsyncMock(return_value=[])
+ ap.app.AGENT_FUNCTION.is_workflow_tagging_enabled = AsyncMock(return_value=False)
+ assert client.get("/v1/workflows?tags=env:prod").status_code == 403
+
+
+def test_get_workflows_without_tag_filter_succeeds_when_disabled(client: TestClient) -> None:
+ from skyvern.forge.sdk.routes import agent_protocol as ap
+
+ ap.app.WORKFLOW_SERVICE.get_workflows_by_organization_id = AsyncMock(return_value=[])
+ ap.app.AGENT_FUNCTION.is_workflow_tagging_enabled = AsyncMock(return_value=False)
+ assert client.get("/v1/workflows").status_code == 200
+
+
+def test_get_workflows_with_tag_filter_succeeds_when_enabled(client: TestClient) -> None:
+ from skyvern.forge.sdk.routes import agent_protocol as ap
+
+ ap.app.WORKFLOW_SERVICE.get_workflows_by_organization_id = AsyncMock(return_value=[])
+ ap.app.AGENT_FUNCTION.is_workflow_tagging_enabled = AsyncMock(return_value=True)
+ assert client.get("/v1/workflows?tags=env:prod").status_code == 200
+
+
# ----------------------------- GET /workflows/{wpid}/tags/history --------------------
diff --git a/tests/unit/test_workflows_list_tag_filter.py b/tests/unit/test_workflows_list_tag_filter.py
index 287820283..7d091799b 100644
--- a/tests/unit/test_workflows_list_tag_filter.py
+++ b/tests/unit/test_workflows_list_tag_filter.py
@@ -313,6 +313,7 @@ def route_client(monkeypatch: pytest.MonkeyPatch) -> TestClient:
app_mock.WORKFLOW_SERVICE = service_mock
# template=true path: empty global list short-circuits to [] before any service call.
app_mock.STORAGE.retrieve_global_workflows = AsyncMock(return_value=[])
+ app_mock.AGENT_FUNCTION.is_workflow_tagging_enabled = AsyncMock(return_value=True)
monkeypatch.setattr(ap, "app", app_mock)
test_app = FastAPI()