{"record":{"id":"02e7a4cc557eea07","repo":"windmill-labs/windmill","slug":"resource-at-path-path-does-not-exist-and-no-typ","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":"backend/windmill-runtime-nativets/src/windmill-client.js","lineNumber":10032,"sourceCode":"  return state_path;\n}\nasync function setResource(value, path, initializeToTypeIfNotExist) {\n  !clientSet && setClient();\n  path = path ?? getStatePath();\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}\nasync function setState(state) {\n  await setResource(state, void 0, \"state\");\n}\nasync function setFlowUserState(key, value, errorIfNotPossible) {\n  !clientSet && setClient();\n  if (value === void 0) {\n    value = null;\n  }\n  const workspace = getWorkspace();\n  try {\n    await JobService.setFlowUserState({\n      workspace,\n      id: await getRootJobId(),\n      key,","sourceCodeStart":10014,"sourceCodeEnd":10050,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-runtime-nativets/src/windmill-client.js#L10014-L10050","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass a resource type as the third argument, e.g. setResource(value, path, 'state') or your schema type name","Pre-create the resource in the Windmill UI or via ResourceService.createResource before writing","Verify the path spelling matches the existing resource exactly","Use setState() for state objects — it initializes with the built-in 'state' type"],"exampleFix":"// before\nawait setResource({ count: 1 }, 'u/admin/counter'); // throws if counter doesn't exist\n// after\nawait setResource({ count: 1 }, 'u/admin/counter', 'object'); // initializes if missing","handlingStrategy":"fallback","validationCode":"let exists = true;\ntry { await getResource(path); } catch { exists = false; }\nif (!exists && !resourceType) throw new Error(`supply initializeToTypeIfNotExist for ${path}`);","typeGuard":"function isInitializable(type) { return typeof type === 'string' && type.length > 0; }","tryCatchPattern":"try {\n  await setResource(value, path);\n} catch (e) {\n  if (String(e.message).includes('does not exist')) await setResource(value, path, 'object');\n  else throw e;\n}","preventionTips":["Always pass a resource type on first writes to a path","Seed required resources in the workspace via deploy scripts","Use setState() for state so the built-in 'state' type initializes it","Verify path spelling to avoid update-vs-create confusion"],"tags":["windmill","resource","initialization","not-found"],"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"}