fix: remove list webhook db call (not needed, causes race condition) (#257)
* fix: remove get_workspace call from list_webhooks (not necessary, causes race condition) * fix: remove old test
This commit is contained in:
parent
342d72184a
commit
1df47e61c8
|
|
@ -63,7 +63,7 @@ async def get_or_create_webhook_endpoint(
|
|||
|
||||
|
||||
async def list_webhook_endpoints(
|
||||
db: AsyncSession, workspace_name: str
|
||||
workspace_name: str,
|
||||
) -> Select[tuple[models.WebhookEndpoint]]:
|
||||
"""
|
||||
List all webhook endpoints, optionally filtered by workspace.
|
||||
|
|
@ -75,9 +75,6 @@ async def list_webhook_endpoints(
|
|||
Returns:
|
||||
List of webhook endpoints
|
||||
"""
|
||||
# Verify workspace exists
|
||||
await get_workspace(db, workspace_name)
|
||||
|
||||
return select(models.WebhookEndpoint).where(
|
||||
models.WebhookEndpoint.workspace_name == workspace_name
|
||||
)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ async def list_webhook_endpoints(
|
|||
if not jwt_params.ad and jwt_params.w is not None and jwt_params.w != workspace_id:
|
||||
raise AuthenticationException("Unauthorized access to resource")
|
||||
|
||||
stmt = await crud.list_webhook_endpoints(db, workspace_id)
|
||||
stmt = await crud.list_webhook_endpoints(workspace_id)
|
||||
return await apaginate(db, stmt)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ async def _get_webhook_urls(db: AsyncSession, workspace_name: str) -> list[str]:
|
|||
Get all webhook endpoint URLs for a workspace.
|
||||
"""
|
||||
try:
|
||||
endpoints = await list_webhook_endpoints(db, workspace_name)
|
||||
endpoints = await list_webhook_endpoints(workspace_name)
|
||||
result = await db.execute(endpoints)
|
||||
return [endpoint.url for endpoint in result.scalars().all()]
|
||||
except Exception:
|
||||
|
|
|
|||
|
|
@ -95,13 +95,6 @@ async def test_list_webhook_endpoints_with_data(
|
|||
assert "http://example2.com/webhook" in endpoint_urls
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_webhook_endpoints_missing_workspace(client: TestClient):
|
||||
response = client.get("/v2/workspaces/nonexistent-workspace/webhooks")
|
||||
assert response.status_code == 404
|
||||
assert response.json() == {"detail": "Workspace nonexistent-workspace not found"}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_delete_webhook_endpoint(
|
||||
client: TestClient, sample_data: tuple[Workspace, Peer]
|
||||
|
|
|
|||
Loading…
Reference in New Issue