{"record":{"id":"5fff85b9f8519dac","repo":"windmill-labs/windmill","slug":"await-res-text","errorCode":null,"errorMessage":"await res.text()","messagePattern":"await res\\.text\\(\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/TestConnection.svelte","lineNumber":69,"sourceCode":"\t\t\tsecret_key: s3.secretKey,\n\t\t\tpath_style: s3.pathStyle\n\t\t}),\n\t\tazure_blob: (s3) => ({ type: 'Azure', ...s3 }),\n\t\ts3_bucket: (bucket) => bucket\n\t}\n\n\tconst OBJECT_STORAGE_TEST_SCRIPT = `\nexport async function main(bucket: any, api_token: string) {\n\tconst res = await fetch(process.env.BASE_URL + '/api/settings/test_object_storage_config', {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\t'Content-Type': 'application/json',\n\t\t\tAuthorization: 'Bearer ' + api_token,\n\t\t},\n\t\tbody: JSON.stringify(bucket),\n\t})\n\tif (!res.ok) {\n\t\tthrow new Error(await res.text())\n\t}\n\treturn await res.text()\n}\n`\n\n\tconst scripts: {\n\t\t[key: string]: {\n\t\t\tcode: string\n\t\t\tlang: string\n\t\t\targName: string\n\t\t\t// Shown as an info tooltip next to the button, e.g. to clarify where the test executes\n\t\t\ttooltip?: string\n\t\t\tadditionalCheck?: (testResult: CompletedJob) => CompletedJob\n\t\t}\n\t} = {\n\t\tpostgresql: {\n\t\t\tcode: `SELECT 1`,\n\t\t\tlang: 'postgresql',","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/TestConnection.svelte#L51-L87","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nif (!res.ok) {\n  throw new Error(await res.text())\n}\n// after\nif (!res.ok) {\n  const body = await res.text()\n  throw new Error(`Request failed (${res.status}): ${body || res.statusText}`)\n}","handlingStrategy":"try-catch","validationCode":"// before calling the endpoint from generated code\nif (!api_token || typeof api_token !== 'string') throw new Error('Missing API token')","typeGuard":null,"tryCatchPattern":"try {\n  const result = await upload(bucket)\n} catch (e) {\n  // error message is the raw response body; inspect status via wrapped fetch if needed\n  console.error('Project request failed:', e.message)\n  throw e\n}","preventionTips":["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"],"tags":["http","generated-script","api-token","hub"],"backgroundTag":"http-error-response","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"}