windmill-labs/windmill · error · Error

path or hash_ must be provided

Error message

path or hash_ must be provided

What it means

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.

Source

Thrown at backend/windmill-runtime-nativets/src/windmill-client.js:9996

  const params = {};
  if (scheduledInSeconds) {
    params["scheduled_in_secs"] = scheduledInSeconds;
  }
  let parentJobId = getEnv("WM_JOB_ID");
  if (parentJobId !== void 0) {
    params["parent_job"] = parentJobId;
  }
  let rootJobId = getEnv("WM_ROOT_FLOW_JOB_ID");
  if (rootJobId != void 0 && rootJobId != "") {
    params["root_job"] = rootJobId;
  }
  let endpoint;
  if (path) {
    endpoint = `/w/${getWorkspace()}/jobs/run/p/${path}`;
  } else if (hash_) {
    endpoint = `/w/${getWorkspace()}/jobs/run/h/${hash_}`;
  } else {
    throw new Error("path or hash_ must be provided");
  }
  let url = new URL(OpenAPI.BASE + endpoint);
  url.search = new URLSearchParams(params).toString();
  return fetch(url, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bearer ${OpenAPI.TOKEN}`,
    },
    body: JSON.stringify(args),
  }).then((res) => res.text());
}
function getStatePath() {
  const state_path = getEnv("WM_STATE_PATH_NEW") ?? getEnv("WM_STATE_PATH");
  if (state_path === void 0) {
    throw Error("State path not set");
  }
  return state_path;

View on GitHub (pinned to e474e8803c)

Solutions

  1. Provide either `path` (e.g. 'f/scripts/my_script') or `hash_` (deployed script hash) — exactly one.
  2. Validate inputs before calling: throw early with the caller's context.
  3. Check the config/env source of the path; log it if it arrives empty.

Example fix

// before
const p = process.env.MY_SCRIPT_PATH; // undefined
await runScriptAsync(p, null, args);
// after
const p = process.env.MY_SCRIPT_PATH;
if (!p) throw new Error('MY_SCRIPT_PATH must be set');
await runScriptAsync(p, null, args);
Defensive patterns

Strategy: validation

Validate before calling

function assertScriptSelector(path, hash_) {
  if (!path && !hash_) {
    throw new Error(`No script selector: set MY_SCRIPT_PATH or MY_SCRIPT_HASH (got path=${JSON.stringify(path)}, hash=${JSON.stringify(hash_)})`);
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/a566498a182ba733. Report an issue: GitHub.