{"record":{"id":"a695c479b9ef0c85","repo":"windmill-labs/windmill","slug":"variable-not-found-at-path-or-not-visible-to-yo","errorCode":null,"errorMessage":"Variable not found at ${path} or not visible to you: ${e.body} ${e}","messagePattern":"Variable not found at (.+?) or not visible to you: (.+?) (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"backend/windmill-runtime-nativets/src/windmill-client.js","lineNumber":10087,"sourceCode":"    });\n  } catch (e) {\n    if (errorIfNotPossible) {\n      throw Error(`Error setting flow user state at ${key}: ${e.body}`);\n    } else {\n      console.error(`Error setting flow user state at ${key}: ${e.body}`);\n    }\n  }\n}\nasync function getState() {\n  return await getResource(getStatePath(), true);\n}\nasync function getVariable(path) {\n  !clientSet && setClient();\n  const workspace = getWorkspace();\n  try {\n    return await VariableService.getVariableValue({ workspace, path });\n  } catch (e) {\n    throw Error(\n      `Variable not found at ${path} or not visible to you: ${e.body} ${e}`\n    );\n  }\n}\nasync function setVariable(\n  path,\n  value,\n  isSecretIfNotExist,\n  descriptionIfNotExist\n) {\n  !clientSet && setClient();\n  const workspace = getWorkspace();\n  if (await VariableService.existsVariable({ workspace, path })) {\n    await VariableService.updateVariable({\n      workspace,\n      path,\n      requestBody: { value },\n    });","sourceCodeStart":10069,"sourceCodeEnd":10105,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-runtime-nativets/src/windmill-client.js#L10069-L10105","documentation":"`getVariable(path)` in Windmill's runtime client calls `VariableService.getVariableValue` and rethrows any API error with this message. Despite the wording, it covers every failure of the variable lookup — not only a missing variable but also insufficient permission, since variables are permission-scoped and the API hides variables you cannot read.","triggerScenarios":"Calling `wmill.getVariable('u/user/myvar')` (or using `$$var` resolution) when: the variable does not exist at that path; the path is mistyped or missing the folder prefix; the variable lives in another workspace; the caller's token lacks read access to the variable's folder.","commonSituations":"Typos or wrong case in variable paths; moving a variable between folders without updating scripts; a colleague's script referencing a private variable in `u/<their-username>/`; switching workspaces between local dev and production where the variable was only created in one.","solutions":["Verify the exact variable path (including folder prefix like `u/<user>/` or `f/<folder>/`) in the Windmill UI Variables page of the target workspace.","If the path is correct, check permissions: share the variable's folder with the runner's identity or move it to a folder the script can read.","Read `e.body` from the message to distinguish 404 (missing) from 403 (not visible to you) and fix accordingly.","Create the variable in the target workspace if it only exists in another environment, then retry."],"exampleFix":"// before\nconst key = await wmill.getVariable('api_key'); // no folder prefix\n// after\nconst key = await wmill.getVariable('u/admin/api_key'); // full path as shown in the UI","handlingStrategy":"validation","validationCode":"async function assertVariableExists(path) {\n  const vars = await wmill.listVariables();\n  return vars.some(v => v.path === path);\n}","typeGuard":null,"tryCatchPattern":"let value;\ntry {\n  value = await wmill.getVariable(path);\n} catch (e) {\n  if (/not found|not visible/.test(e.message)) {\n    throw new Error(`Variable ${path} missing or unreadable in this workspace: check path and folder permissions`);\n  }\n  throw e;\n}","preventionTips":["Copy variable paths directly from the Windmill UI instead of typing them.","Keep shared variables in folders (f/...) shared with the workspace, not in private u/ paths.","Ensure variables exist in every environment/workspace your code deploys to.","Prefer passing secrets as script parameters/resources over hard-coded paths."],"tags":["windmill","variables","permissions","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"}