Skip to content

Commit 6a69958

Browse files
committed
Fix webhook wait response schema
1 parent 5da8f9b commit 6a69958

5 files changed

Lines changed: 22 additions & 45 deletions

File tree

frontend/src/client/schemas.gen.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21894,34 +21894,6 @@ export const $WaitResultUnwrapOverflowResponse = {
2189421894
title: "WaitResultUnwrapOverflowResponse",
2189521895
} as const
2189621896

21897-
export const $WaitResultUnwrappedOutput = {
21898-
anyOf: [
21899-
{
21900-
additionalProperties: true,
21901-
type: "object",
21902-
},
21903-
{
21904-
items: {},
21905-
type: "array",
21906-
},
21907-
{
21908-
type: "string",
21909-
},
21910-
{
21911-
type: "integer",
21912-
},
21913-
{
21914-
type: "number",
21915-
},
21916-
{
21917-
type: "boolean",
21918-
},
21919-
{
21920-
type: "null",
21921-
},
21922-
],
21923-
} as const
21924-
2192521897
export const $WaitStrategy = {
2192621898
type: "string",
2192721899
enum: ["wait", "detach"],

frontend/src/client/services.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ export const publicIncomingWebhookGet = (
817817
* @param data.workflowId
818818
* @param data.unwrap Return the workflow result directly as the response body, without the `{kind, value}` envelope. Requires the result to fit inline. If the result was externalized, returns 413 with the download envelope in `detail`.
819819
* @param data.contentType
820-
* @returns unknown Successful Response
820+
* @returns WaitResultOutput Successful Response
821821
* @throws ApiError
822822
*/
823823
export const publicIncomingWebhookWait = (

frontend/src/client/types.gen.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6762,16 +6762,6 @@ export type WaitResultUnwrapOverflowResponse = {
67626762
detail: WebhookStoredObjectDownloadResponse
67636763
}
67646764

6765-
export type WaitResultUnwrappedOutput =
6766-
| {
6767-
[key: string]: unknown
6768-
}
6769-
| Array<unknown>
6770-
| string
6771-
| number
6772-
| boolean
6773-
| null
6774-
67756765
export type WaitStrategy = "wait" | "detach"
67766766

67776767
/**
@@ -8004,9 +7994,7 @@ export type PublicIncomingWebhookWaitData = {
80047994
workflowId: string
80057995
}
80067996

8007-
export type PublicIncomingWebhookWaitResponse =
8008-
| WaitResultOutput
8009-
| WaitResultUnwrappedOutput
7997+
export type PublicIncomingWebhookWaitResponse = WaitResultOutput
80107998

80117999
export type PublicIncomingWebhookDraftData = {
80128000
contentType?: string | null
@@ -10980,7 +10968,7 @@ export type $OpenApiTs = {
1098010968
/**
1098110969
* Successful Response
1098210970
*/
10983-
200: WaitResultOutput | WaitResultUnwrappedOutput
10971+
200: WaitResultOutput
1098410972
/**
1098510973
* Unwrapped workflow result exceeded inline response limits. Use `detail.download_url` to fetch the externalized result.
1098610974
*/

tests/unit/test_webhook_execution_path.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from unittest.mock import AsyncMock, MagicMock, patch
2020

2121
import pytest
22-
from fastapi import HTTPException, Request
22+
from fastapi import FastAPI, HTTPException, Request
2323
from fastapi.responses import JSONResponse
2424
from temporalio.client import Client
2525
from temporalio.common import TypedSearchAttributes, WorkflowIDReusePolicy
@@ -37,6 +37,7 @@
3737
)
3838
from tracecat.storage.utils import deserialize_object
3939
from tracecat.webhooks.router import _incoming_webhook, incoming_webhook_wait
40+
from tracecat.webhooks.router import router as webhook_router
4041
from tracecat.workflow.executions.enums import (
4142
ExecutionType,
4243
TemporalSearchAttr,
@@ -1051,6 +1052,22 @@ async def test_wait_webhook_unwrap_returns_413_for_collection_object(self):
10511052
assert detail["kind"] == "download_export"
10521053
assert detail["download_url"] == "https://example.com/presigned/collection"
10531054

1055+
def test_wait_webhook_openapi_keeps_default_200_schema_enveloped(self):
1056+
"""The default /wait 200 schema should stay discriminated for generated clients."""
1057+
app = FastAPI()
1058+
app.include_router(webhook_router)
1059+
1060+
responses = app.openapi()["paths"]["/webhooks/{workflow_id}/{secret}/wait"][
1061+
"post"
1062+
]["responses"]
1063+
success_schema = responses["200"]["content"]["application/json"]["schema"]
1064+
overflow_schema = responses["413"]["content"]["application/json"]["schema"]
1065+
1066+
assert success_schema == {"$ref": "#/components/schemas/WaitResultOutput"}
1067+
assert overflow_schema == {
1068+
"$ref": "#/components/schemas/WaitResultUnwrapOverflowResponse"
1069+
}
1070+
10541071

10551072
# ---------------------------------------------------------------------------
10561073
# _dispatch_workflow invariants (for /wait webhook endpoint)

tracecat/webhooks/router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ async def _incoming_webhook(
396396

397397
@router.post(
398398
"/wait",
399-
response_model=WaitResultOutput | WaitResultUnwrappedOutput,
399+
response_model=WaitResultOutput,
400400
responses={
401401
status.HTTP_413_REQUEST_ENTITY_TOO_LARGE: {
402402
"model": WaitResultUnwrapOverflowResponse,

0 commit comments

Comments
 (0)