{"record":{"id":"45c6ac55ad7bdb0f","repo":"windmill-labs/windmill","slug":"resource-at-path-path-does-not-exist-and-no-typ-45c6ac","errorCode":null,"errorMessage":"Resource at path ${path} does not exist and no type was provided to initialize it","messagePattern":"Resource at path (.+?) does not exist and no type was provided to initialize it","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"typescript-client/client.ts","lineNumber":625,"sourceCode":"  const mockedApi = await getMockedApi();\n  if (mockedApi) {\n    mockedApi.resources[path] = value;\n    return;\n  }\n  const workspace = getWorkspace();\n  if (await ResourceService.existsResource({ workspace, path })) {\n    await ResourceService.updateResourceValue({\n      workspace,\n      path,\n      requestBody: { value },\n    });\n  } else if (initializeToTypeIfNotExist) {\n    await ResourceService.createResource({\n      workspace,\n      requestBody: { path, value, resource_type: initializeToTypeIfNotExist },\n    });\n  } else {\n    throw Error(\n      `Resource at path ${path} does not exist and no type was provided to initialize it`\n    );\n  }\n}\n\n/**\n * Set the state\n * @param state state to set\n * @deprecated use setState instead\n */\nexport async function setInternalState(state: any): Promise<void> {\n  await setResource(state, undefined, \"state\");\n}\n\n/**\n * Set the state\n * @param state state to set\n * @param path Optional state resource path override. Defaults to `getStatePath()`.","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/typescript-client/client.ts#L607-L643","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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)."],"exampleFix":"// before\nawait setResource({ items: [] }, 'u/admin/results');\n// after\nawait setResource({ items: [] }, 'u/admin/results', 'object');","handlingStrategy":"validation","validationCode":"import { ResourceService } from './sdk';\nconst exists = await ResourceService.existsResource({ workspace, path });\nif (!exists && !resourceType) {\n  throw new Error(`Resource ${path} missing; pass initializeToTypeIfNotExist before calling setResource`);\n}","typeGuard":"function isSettableResourceTarget(\n  target: { path: string; type?: string }\n): target is { path: string; type: string } {\n  return typeof target.path === 'string' && target.path.length > 0 && typeof target.type === 'string';\n}","tryCatchPattern":"try {\n  await setResource(value, path);\n} catch (e) {\n  if (String(e).includes('does not exist')) {\n    await setResource(value, path, 'object'); // retry with creation type\n  } else {\n    throw e;\n  }\n}","preventionTips":["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'."],"tags":["windmill","resources","missing-resource","api"],"backgroundTag":"resource-not-found","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"}