{"record":{"id":"39a4af4b109be720","repo":"windmill-labs/windmill","slug":"variable-not-found-at-path-or-not-visible-to-yo-39a4af","errorCode":null,"errorMessage":"Variable not found at ${path} or not visible to you: ${e.body}","messagePattern":"Variable not found at (.+?) or not visible to you: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"typescript-client/client.ts","lineNumber":788,"sourceCode":" * @returns variable value\n */\nexport async function getVariable(path: string): Promise<string> {\n  path = parseVariableSyntax(path) ?? path;\n  const mockedApi = await getMockedApi();\n  if (mockedApi) {\n    if (mockedApi.variables[path]) {\n      return mockedApi.variables[path];\n    } else {\n      console.log(\n        `MockedAPI present, but variable not found at ${path}, falling back to real API`\n      );\n    }\n  }\n  const workspace = getWorkspace();\n  try {\n    return await VariableService.getVariableValue({ workspace, path });\n  } catch (e: any) {\n    throw Error(\n      `Variable not found at ${path} or not visible to you: ${e.body}`\n    );\n  }\n}\n\n/**\n * Set a variable by path, create if not exist\n * @param path path of the variable\n * @param value value of the variable\n * @param isSecretIfNotExist if the variable does not exist, create it as secret or not (default: false)\n * @param descriptionIfNotExist if the variable does not exist, create it with this description (default: \"\")\n */\nexport async function setVariable(\n  path: string,\n  value: string,\n  isSecretIfNotExist?: boolean,\n  descriptionIfNotExist?: string\n): Promise<void> {","sourceCodeStart":770,"sourceCodeEnd":806,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/typescript-client/client.ts#L770-L806","documentation":"getVariable() fetches a variable's value by path via VariableService.getVariableValue. Any API error is rethrown with this message — covering both a genuinely missing path and permission/visibility problems, since Windmill hides variables the caller cannot see (404-style responses for both). The server's error body is appended for diagnosis.","triggerScenarios":"Calling getVariable('f/...') or getVariable('u/...') with a typo'd/non-existent path; the variable is secret and the token/workspace lacks permission; the variable lives in another workspace; getVariable('$res:...')-style syntax confusion after parseVariableSyntax; path with stale variable reference in a deployed script.","commonSituations":"Renaming or deleting a variable while scripts still reference it; CI token without variable read scope; copying a script across workspaces; promoting code between dev/prod instances where the variable wasn't recreated.","solutions":["Verify the exact variable path in the Windmill UI (Variables page) — copy it rather than retyping.","Confirm the variable exists in the workspace your script runs in (WM_WORKSPACE), and your token has read access to it.","Create the missing variable (`wmill variable create` or UI) with the same path.","Check e.body in the message: 404 usually means missing or hidden; 403 means permissions.","Use $variables syntax or wmill variable list to audit references before renaming/deleting."],"exampleFix":"// before\nconst apiKey = await getVariable('f/deployment/api_key');\n// after\ntry {\n  const apiKey = await getVariable('f/deployment/api_key');\n} catch (e) {\n  console.error('variable missing or not visible; check path/permissions in this workspace');\n  throw e;\n}","handlingStrategy":"validation","validationCode":"import { VariableService } from './sdk';\nconst vars = await VariableService.listVariables({ workspace }); // or `wmill variable list`\nif (!vars.some((v) => v.path === path)) {\n  throw new Error(`Variable ${path} must be provisioned before running`);\n}","typeGuard":null,"tryCatchPattern":"let apiKey: string;\ntry {\n  apiKey = await getVariable('f/deployment/api_key');\n} catch (e) {\n  console.error(`Variable lookup failed: ${e.message}`); // includes server e.body\n  throw new Error(`Required variable missing or not visible in this workspace`);\n}","preventionTips":["Provision variables (including secrets) in every workspace/instance the script deploys to.","Copy variable paths from the UI instead of retyping them.","Check token scopes: the caller needs variable read permission or the variable appears 'not found'.","Use `wmill variable list` in CI as a pre-deploy sanity check for referenced paths."],"tags":["windmill","variables","missing-resource","permissions","api"],"backgroundTag":"variable-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"}