windmill-labs/windmill · error · Error

Resource at path ${path} does not exist and no type was prov

Error message

Resource at path ${path} does not exist and no type was provided to initialize it

What it means

setResource tries to write a resource at a path; if the resource does not exist and the caller did not pass initializeToTypeIfNotExist (a resource type), the library throws this Error. It is the library's explicit refusal to create a resource with an unknown type.

Source

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

  return state_path;
}
async function setResource(value, path, initializeToTypeIfNotExist) {
  !clientSet && setClient();
  path = path ?? getStatePath();
  const workspace = getWorkspace();
  if (await ResourceService.existsResource({ workspace, path })) {
    await ResourceService.updateResourceValue({
      workspace,
      path,
      requestBody: { value },
    });
  } else if (initializeToTypeIfNotExist) {
    await ResourceService.createResource({
      workspace,
      requestBody: { path, value, resource_type: initializeToTypeIfNotExist },
    });
  } else {
    throw Error(
      `Resource at path ${path} does not exist and no type was provided to initialize it`
    );
  }
}
async function setState(state) {
  await setResource(state, void 0, "state");
}
async function setFlowUserState(key, value, errorIfNotPossible) {
  !clientSet && setClient();
  if (value === void 0) {
    value = null;
  }
  const workspace = getWorkspace();
  try {
    await JobService.setFlowUserState({
      workspace,
      id: await getRootJobId(),
      key,

View on GitHub (pinned to e474e8803c)

Solutions

  1. Pass a resource type as the third argument, e.g. setResource(value, path, 'state') or your schema type name
  2. Pre-create the resource in the Windmill UI or via ResourceService.createResource before writing
  3. Verify the path spelling matches the existing resource exactly
  4. Use setState() for state objects — it initializes with the built-in 'state' type

Example fix

// before
await setResource({ count: 1 }, 'u/admin/counter'); // throws if counter doesn't exist
// after
await setResource({ count: 1 }, 'u/admin/counter', 'object'); // initializes if missing
Defensive patterns

Strategy: fallback

Validate before calling

let exists = true;
try { await getResource(path); } catch { exists = false; }
if (!exists && !resourceType) throw new Error(`supply initializeToTypeIfNotExist for ${path}`);

Type guard

function isInitializable(type) { return typeof type === 'string' && type.length > 0; }

Try / catch

try {
  await setResource(value, path);
} catch (e) {
  if (String(e.message).includes('does not exist')) await setResource(value, path, 'object');
  else throw e;
}

Prevention

When it happens

Trigger: Calling setResource(value, path) or setResource(value, path, undefined) where no resource exists at path, so the update fails 404 and the create branch has no resource_type to use. setState avoids this by passing 'state' as the init type.

Common situations: Typo in the path so an existing-resource update turns into a create; first-ever write to a state/resource path before initialization; migrating scripts to a new workspace without seeding resources; passing empty string or null as the third argument instead of a type.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — 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/02e7a4cc557eea07. Report an issue: GitHub.