{"record":{"id":"95900494e7e0a3f8","repo":"windmill-labs/windmill","slug":"req-status-req-statustext-await-req-te","errorCode":null,"errorMessage":"${req.status} - ${req.statusText} - ${await req.text()}","messagePattern":"\\$\\{req\\.status\\} - \\$\\{req\\.statusText\\} - \\$\\{await req\\.text\\(\\)\\}","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/script/script.ts","lineNumber":1001,"sourceCode":"    try {\n      const url =\n        workspace.remote +\n        \"api/w/\" +\n        workspaceId +\n        \"/scripts/create?\" +\n        skipIfNoop;\n      const req = await fetch(url, {\n        method: \"POST\",\n        headers: {\n          Authorization: `Bearer ${workspace.token}`,\n          \"Content-Type\": \"application/json\",\n          ...extraHeaders,\n        },\n        body: JSON.stringify(body),\n      });\n      await detectAuthGatewayChallenge(req, url);\n      if (req.status != 201) {\n        throw Error(\n          `${req.status} - ${req.statusText} - ${await req.text()}`\n        );\n      }\n    } catch (e: any) {\n      throw Error(\n        `Script creation for ${body.path} with parent ${\n          body.parent_hash\n        }  was not successful: ${e.body ?? e.message} `\n      );\n    }\n  } else {\n    const form = new FormData();\n    form.append(\"script\", JSON.stringify(body));\n    form.append(\n      \"file\",\n      typeof bundleContent == \"string\"\n        ? bundleContent\n        : bundleContent","sourceCodeStart":983,"sourceCodeEnd":1019,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/script/script.ts#L983-L1019","documentation":"createScript in the Windmill CLI POSTs to /scripts/create and throws a raw HTTP error when the backend does not return 201. The message embeds status code, status text and the response body, which carries the server-side validation reason (e.g. invalid path, schema error).","triggerScenarios":"Calling `wmill script push`/create for a script without a bundleContent: fetch to api/w/{workspace}/scripts/create?skip_if_noop=true returns a non-201 status (400 invalid payload, 401/403 auth, 409 path conflict, 500 server error).","commonSituations":"Invalid script path format; expired or wrong workspace token; path already taken by another object type; backend rejecting schema; wrong --remote URL pointing at a non-Windmill service.","solutions":["Read the response body in the error message — it contains the server's concrete rejection reason","Check the workspace token/login (`wmill auth login`) and that the workspace is correct","Validate the script path format (must match Windmill path rules) and fix it","Verify the --remote URL points at the correct Windmill instance"],"exampleFix":"// before\nwmill script push f/scripts/my -h badparent\n// after\nwmill script push f/scripts/my_script --parent <valid-hash>  # and a valid token via wmill auth login","handlingStrategy":"try-catch","validationCode":"const probe = await fetch(workspace.remote + 'api/w/' + workspaceId + '/workspaces/get', { headers: { Authorization: `Bearer ${workspace.token}` } }); if (probe.status !== 200) throw new Error(`Auth/remote check failed: ${probe.status}`);","typeGuard":null,"tryCatchPattern":"try { await createScript(...); } catch (e) { console.error(`Script ${body.path} creation failed: ${e.message}`); if (e.message.startsWith('401') || e.message.startsWith('403')) { await relogin(); } }","preventionTips":["Re-authenticate before long deploy sessions (tokens expire)","Validate script paths against Windmill path rules before pushing","Confirm --remote points at the correct instance"],"tags":["http","api","cli","deploy"],"backgroundTag":"http-request-failed","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"}