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() updates an existing resource's value, but if no resource exists at the target path it can only CREATE one when you pass initializeToTypeIfNotExist (a resource type name), since Windmill resources require a type at creation. When the resource is missing and no type was provided, the library throws instead of guessing a type.
Source
Thrown at typescript-client/client.ts:625
const mockedApi = await getMockedApi();
if (mockedApi) {
mockedApi.resources[path] = value;
return;
}
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`
);
}
}
/**
* Set the state
* @param state state to set
* @deprecated use setState instead
*/
export async function setInternalState(state: any): Promise<void> {
await setResource(state, undefined, "state");
}
/**
* Set the state
* @param state state to set
* @param path Optional state resource path override. Defaults to `getStatePath()`.View on GitHub (pinned to e474e8803c)
Solutions
- Create the resource beforehand (UI, `wmill resource create`, or VariableService/ResourceService) at the exact path.
- Pass a resource type as the third argument: `setResource(value, path, object_type_name)` so it gets created if missing.
- Verify the path spelling and that you are targeting the intended workspace.
- Check your token's permissions can see the resource (existsResource returning false also triggers this).
Example fix
// before
await setResource({ items: [] }, 'u/admin/results');
// after
await setResource({ items: [] }, 'u/admin/results', 'object'); Defensive patterns
Strategy: validation
Validate before calling
import { ResourceService } from './sdk';
const exists = await ResourceService.existsResource({ workspace, path });
if (!exists && !resourceType) {
throw new Error(`Resource ${path} missing; pass initializeToTypeIfNotExist before calling setResource`);
} Type guard
function isSettableResourceTarget(
target: { path: string; type?: string }
): target is { path: string; type: string } {
return typeof target.path === 'string' && target.path.length > 0 && typeof target.type === 'string';
} Try / catch
try {
await setResource(value, path);
} catch (e) {
if (String(e).includes('does not exist')) {
await setResource(value, path, 'object'); // retry with creation type
} else {
throw e;
}
} Prevention
- Always pass the resource type as setResource's third argument when the path may not exist yet.
- Provision resources via wmill CLI / IaC before deploying scripts that write to them.
- Double-check resource paths and workspace when you get this error; typos silently read as 'missing'.
- Use setState() for state persistence — it auto-initializes with type 'state'.
When it happens
Trigger: Calling setResource(value, path) where no resource exists at `path` and no third argument is given. Notably setState() always passes type 'state', so this is hit by direct setResource calls (or setInternalState misuse) targeting a non-existent path — typically a typo'd path, wrong workspace, or a path the token cannot see (existsResource returns false).
Common situations: Referring to a resource that was deleted or renamed; running in a different workspace than where the resource lives; forgetting the `initializeToTypeIfNotExist` argument when writing results to a fresh path; permission scope hiding the resource so existsResource is false.
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
- Variable not found at ${path} or not visible to you: ${e.bod
- Variable not found at ${path} or not visible to you: ${e.bod
- Error setting flow user state at ${key}: ${e.body}
- Failed to re-run job ${id}.
- Failed to push completed jobs: ${e}
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/45c6ac55ad7bdb0f.
Report an issue: GitHub.