{"record":{"id":"f22bbf8a37ff54de","repo":"windmill-labs/windmill","slug":"response-body-is-empty","errorCode":null,"errorMessage":"Response body is empty","messagePattern":"Response body is empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"frontend/src/lib/components/triggers/webhook/WebhooksConfigSection.svelte","lineNumber":132,"sourceCode":"\n\tfunction fetchCode() {\n\t\tif (requestType === 'sync_sse') {\n\t\t\treturn `import { EventSource } from \"eventsource\";\n\nexport async function main() {\n  const response = await fetch(\\`${url}\\`, {\n    method: '${callMethod === 'get' ? 'GET' : 'POST'}',\n    headers: ${JSON.stringify(headers(), null, 2).replaceAll('\\n', '\\n    ')},\n    body: ${callMethod === 'get' ? 'undefined' : `JSON.stringify(${JSON.stringify(cleanedRunnableArgs ?? {}, null, 2).replaceAll('\\n', '\\n    ')})`}\n  });\n  \n  if (!response.ok) {\n\tconst text = await response.text()\n\tthrow new Error(\\`\\${response.status} \\${text}\\`)\n  }\n\n  if (!response.body) {\n    throw new Error(\"Response body is empty\");\n  }\n\n  const reader = response.body.getReader();\n  const decoder = new TextDecoder();\n  let buffer = \"\";\n\n  try {\n    while (true) {\n      const { done, value } = await reader.read();\n\n      if (done) break;\n\n      buffer += decoder.decode(value, { stream: true });\n      const lines = buffer.split(\"\\\\n\");\n\n      // Keep the last incomplete line in buffer\n      buffer = lines.pop() || \"\";\n","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/triggers/webhook/WebhooksConfigSection.svelte#L114-L150","documentation":"The generated webhook test code checks response.body after the ok check and throws 'Response body is empty' when the streaming body is null. The rest of the snippet streams the body via getReader(), which requires a non-null body, so it fails fast with a clear message.","triggerScenarios":"The endpoint returned a successful (ok) response whose body stream is null — e.g. 204 No Content, HEAD request, or an environment/proxy stripping the body.","commonSituations":"Webhook script returns nothing (empty response) so the platform answers 204; testing with GET on an endpoint that returns no payload; misconfigured handler returning an empty 200.","solutions":["Make the webhook script return a value so the response has a body","Use a method (POST/GET) that yields a payload rather than HEAD/204","Catch this case in the generated code and treat an empty body as a valid no-content response"],"exampleFix":"// before\nif (!response.body) { throw new Error(\"Response body is empty\"); }\n// after\nif (!response.body) { console.warn('Empty response body'); return; }","handlingStrategy":"fallback","validationCode":"const res = await fetch(url, { method: 'POST' });\nif (res.status === 204 || res.headers.get('content-length') === '0') {\n  console.warn('Empty body expected');\n}","typeGuard":"function hasReadableBody(res: Response): res is Response & { body: ReadableStream } {\n  return res.body !== null;\n}","tryCatchPattern":"try { await runTest(); } catch (e) {\n  if (e.message === 'Response body is empty') { treatAsNoContent(); }\n  else throw e;\n}","preventionTips":["Ensure the webhook script returns a value so responses carry a body","Avoid HEAD requests or endpoints returning 204 in the test","Treat empty bodies as valid no-content responses instead of errors"],"tags":["http","webhook","response-body","empty"],"backgroundTag":"empty-response-body","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}