{"record":{"id":"a566498a182ba733","repo":"windmill-labs/windmill","slug":"path-or-hash-must-be-provided","errorCode":null,"errorMessage":"path or hash_ must be provided","messagePattern":"path or hash_ must be provided","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"backend/windmill-runtime-nativets/src/windmill-client.js","lineNumber":9996,"sourceCode":"  const params = {};\n  if (scheduledInSeconds) {\n    params[\"scheduled_in_secs\"] = scheduledInSeconds;\n  }\n  let parentJobId = getEnv(\"WM_JOB_ID\");\n  if (parentJobId !== void 0) {\n    params[\"parent_job\"] = parentJobId;\n  }\n  let rootJobId = getEnv(\"WM_ROOT_FLOW_JOB_ID\");\n  if (rootJobId != void 0 && rootJobId != \"\") {\n    params[\"root_job\"] = rootJobId;\n  }\n  let endpoint;\n  if (path) {\n    endpoint = `/w/${getWorkspace()}/jobs/run/p/${path}`;\n  } else if (hash_) {\n    endpoint = `/w/${getWorkspace()}/jobs/run/h/${hash_}`;\n  } else {\n    throw new Error(\"path or hash_ must be provided\");\n  }\n  let url = new URL(OpenAPI.BASE + endpoint);\n  url.search = new URLSearchParams(params).toString();\n  return fetch(url, {\n    method: \"POST\",\n    headers: {\n      \"Content-Type\": \"application/json\",\n      Authorization: `Bearer ${OpenAPI.TOKEN}`,\n    },\n    body: JSON.stringify(args),\n  }).then((res) => res.text());\n}\nfunction getStatePath() {\n  const state_path = getEnv(\"WM_STATE_PATH_NEW\") ?? getEnv(\"WM_STATE_PATH\");\n  if (state_path === void 0) {\n    throw Error(\"State path not set\");\n  }\n  return state_path;","sourceCodeStart":9978,"sourceCodeEnd":10014,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-runtime-nativets/src/windmill-client.js#L9978-L10014","documentation":"runScriptAsync builds the run-job endpoint from either a path (/jobs/run/p/...) or a hash (/jobs/run/h/...). If neither argument is provided it cannot construct a URL and throws this error before making the HTTP request.","triggerScenarios":"Calling runScriptAsync(null, null, args) or runScriptAsync(undefined, undefined, args) — e.g. variables resolved from an empty config, env vars not set, or a lookup that returned nothing.","commonSituations":"MISSING env/config driving the script path, a typo'd variable that resolves to undefined, or refactored call sites where the path argument was dropped.","solutions":["Provide either `path` (e.g. 'f/scripts/my_script') or `hash_` (deployed script hash) — exactly one.","Validate inputs before calling: throw early with the caller's context.","Check the config/env source of the path; log it if it arrives empty."],"exampleFix":"// before\nconst p = process.env.MY_SCRIPT_PATH; // undefined\nawait runScriptAsync(p, null, args);\n// after\nconst p = process.env.MY_SCRIPT_PATH;\nif (!p) throw new Error('MY_SCRIPT_PATH must be set');\nawait runScriptAsync(p, null, args);","handlingStrategy":"validation","validationCode":"function assertScriptSelector(path, hash_) {\n  if (!path && !hash_) {\n    throw new Error(`No script selector: set MY_SCRIPT_PATH or MY_SCRIPT_HASH (got path=${JSON.stringify(path)}, hash=${JSON.stringify(hash_)})`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fail fast at startup when the env/config supplying the script path is empty.","Log the resolved path/hash before calling runScriptAsync.","Use a wrapper that validates exactly-one-of path/hash before invoking the SDK."],"tags":["argument-validation","api-client","scripts","missing-argument"],"backgroundTag":"missing-required-argument","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"}