fix(i-c): BUG-036 behoben — Workflow-Instances GET lieferte 500 auf jeden Aufruf (Route übergab user_id/is_system_admin die die Service-Signatur nicht akzeptierte → TypeError); Service um optionale User-Filterung erweitert (Nicht-Admins sehen nur eigene Instanzen via initiated_by, Admins alle); Beweistest test_bug036_instances.py 2/2 grün

This commit is contained in:
Agent Zero
2026-08-24 21:16:08 +02:00
parent d9aed519f2
commit 84a30d85c2
3 changed files with 48 additions and 2 deletions
+35
View File
@@ -0,0 +1,35 @@
"""Tests for BUG-036 fix — GET /api/v1/workflows/instances returned 500.
Root cause: the route passed ``user_id``/``is_system_admin`` which the service
signature did not accept -> TypeError -> 500 on every call.
"""
from __future__ import annotations
import pytest
from tests.conftest import ORIGIN_HEADER, login_client, seed_tenant_and_users
@pytest.mark.asyncio
async def test_list_instances_returns_200(client, db_session):
"""GET /api/v1/workflows/instances must return 200 (was 500 before fix)."""
await seed_tenant_and_users(db_session)
await login_client(client, "admin@tenanta.com")
resp = await client.get("/api/v1/workflows/instances", headers=ORIGIN_HEADER)
assert resp.status_code == 200, resp.text
data = resp.json()
assert "items" in data and "total" in data
@pytest.mark.asyncio
async def test_list_instances_status_filter_returns_200(client, db_session):
"""Status filter variant also works after the signature fix."""
await seed_tenant_and_users(db_session)
await login_client(client, "admin@tenanta.com")
resp = await client.get(
"/api/v1/workflows/instances?status=running", headers=ORIGIN_HEADER
)
assert resp.status_code == 200, resp.text