windmill-labs/windmill · error · Error
await res.text()
Error message
await res.text()
What it means
TestConnection generates a client script whose connectProject/upload helper throws Error(await res.text()) when the hub/project endpoint responds non-OK. The thrown value is the raw response body from the server, giving the user the upstream error verbatim in their script.
Source
Thrown at frontend/src/lib/components/TestConnection.svelte:69
secret_key: s3.secretKey,
path_style: s3.pathStyle
}),
azure_blob: (s3) => ({ type: 'Azure', ...s3 }),
s3_bucket: (bucket) => bucket
}
const OBJECT_STORAGE_TEST_SCRIPT = `
export async function main(bucket: any, api_token: string) {
const res = await fetch(process.env.BASE_URL + '/api/settings/test_object_storage_config', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + api_token,
},
body: JSON.stringify(bucket),
})
if (!res.ok) {
throw new Error(await res.text())
}
return await res.text()
}
`
const scripts: {
[key: string]: {
code: string
lang: string
argName: string
// Shown as an info tooltip next to the button, e.g. to clarify where the test executes
tooltip?: string
additionalCheck?: (testResult: CompletedJob) => CompletedJob
}
} = {
postgresql: {
code: `SELECT 1`,
lang: 'postgresql',View on GitHub (pinned to e474e8803c)
Solutions
- Read the error body — it is the server's response text and usually states the exact problem (401 invalid token, 404 missing resource, etc.)
- Regenerate the script / re-enter the API token to refresh credentials
- Verify the project slug and bucket names referenced in the script still exist
- If the body is HTML, a proxy/gateway is intercepting — check network configuration
Example fix
// before
if (!res.ok) {
throw new Error(await res.text())
}
// after
if (!res.ok) {
const body = await res.text()
throw new Error(`Request failed (${res.status}): ${body || res.statusText}`)
} Defensive patterns
Strategy: try-catch
Validate before calling
// before calling the endpoint from generated code
if (!api_token || typeof api_token !== 'string') throw new Error('Missing API token') Try / catch
try {
const result = await upload(bucket)
} catch (e) {
// error message is the raw response body; inspect status via wrapped fetch if needed
console.error('Project request failed:', e.message)
throw e
} Prevention
- Regenerate the script when tokens or project slugs change
- Verify bucket names and payloads before upload
- Watch for HTML bodies indicating a proxy intercepting requests
When it happens
Trigger: The generated script's fetch to the project endpoint (POST with a bucket payload, Bearer api_token auth) returns !res.ok — invalid API token, missing project/bucket permissions, or malformed bucket body — and the script throws the response body as the error.
Common situations: Expired or wrong `api_token` embedded in the generated script; the project or bucket was deleted server-side; network proxy returning an HTML error page as the body; server-side validation rejecting the bucket payload.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- Couldn't fetch resource types from hub ${hubBaseUrl}: ${(awa
- Couldn't fetch resource types from public hub:
- raw app ${ref.path} has no compiled bundle — deploy it first
- ${text}
- export ${res.status}: ${text}
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/5fff85b9f8519dac.
Report an issue: GitHub.