{"record":{"id":"32573116745e922f","repo":"windmill-labs/windmill","slug":"job-jobid-was-not-successful-json-stringify-325731","errorCode":null,"errorMessage":"Job ${jobId} was not successful: ${JSON.stringify(error)}","messagePattern":"Job (.+?) was not successful: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"typescript-client/client.ts","lineNumber":306,"sourceCode":"  while (true) {\n    // Implement your HTTP request logic here to get job result\n    const resultRes = await getResultMaybe(jobId);\n\n    const started = resultRes.started;\n    const completed = resultRes.completed;\n    const success = resultRes.success;\n\n    if (!started && verbose) {\n      console.info(`job ${jobId} has not started yet`);\n    }\n\n    if (completed) {\n      const result = resultRes.result;\n      if (success) {\n        return result;\n      } else {\n        const error = result.error;\n        throw new Error(\n          `Job ${jobId} was not successful: ${JSON.stringify(error)}`\n        );\n      }\n    }\n\n    if (verbose) {\n      console.info(`sleeping 0.5 seconds for jobId: ${jobId}`);\n    }\n\n    await new Promise((resolve) => setTimeout(resolve, 500));\n  }\n}\n\n/**\n * Get the result of a completed job\n * @param jobId - ID of the completed job\n * @returns Job result\n */","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/typescript-client/client.ts#L288-L324","documentation":"Thrown by waitJob when the polled job completed with success=false. The job's own `error` field is JSON-serialized into the message, so the text carries the underlying run failure (script exception, invalid args, worker error) — this is the client surfacing a failed execution, not a client-side fault.","triggerScenarios":"Calling runScript*/runFlow* (which await waitJob) when the underlying script/flow execution fails — e.g. an uncaught exception in the script, a failed flow step, or a denied/precondition failure.","commonSituations":"Bugs in the executed script or flow; missing resource/variable at runtime; invalid inputs causing the run to error; flow routing to a failure branch.","solutions":["Read the JSON error payload in the message to find the actual failure cause","Fix the bug in the script/flow that made the run fail","Wrap the call in try/catch if failure is expected and handle the error object","Re-run with verbose logging to see intermediate job state"],"exampleFix":"// before\nconst result = await client.runScriptByPath('etl/job', args)\n// after\ntry {\n  const result = await client.runScriptByPath('etl/job', args)\n} catch (e) {\n  console.error('job failed:', e.message) // includes job id + server error JSON\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const result = await client.runScriptByPath(path, args)\n} catch (e) {\n  if (String(e.message).startsWith('Job ') && e.message.includes('was not successful')) {\n    const payload = JSON.parse(e.message.slice(e.message.indexOf('{')))\n    console.error('Job failed on server:', payload)\n  } else throw e\n}","preventionTips":["Test scripts/flows in the UI before automating them via the client","Pass verbose: true while debugging job failures","Validate inputs against the script's schema before running"],"tags":["job","execution-failure","runtime","api-client"],"backgroundTag":"job-execution-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"}