{"record":{"id":"23dfb595fa818e78","repo":"windmill-labs/windmill","slug":"file-path-must-refer-to-a-file-23dfb5","errorCode":null,"errorMessage":"file path must refer to a file.","messagePattern":"file path must refer to a file\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/resource/resource.ts","lineNumber":177,"sourceCode":"        ...localResource,\n        ...(wsSpecific !== undefined ? { ws_specific: wsSpecific } : {}),\n      },\n    });\n  }\n}\n\ntype PushOptions = GlobalOptions;\nasync function push(opts: PushOptions, filePath: string, remotePath: string) {\n  const workspace = await resolveWorkspace(opts);\n  await requireLogin(opts);\n\n  if (!validatePath(remotePath)) {\n    return;\n  }\n\n  const fstat = await stat(filePath);\n  if (!fstat.isFile()) {\n    throw new Error(\"file path must refer to a file.\");\n  }\n\n  log.info(colors.bold.yellow(\"Pushing resource...\"));\n\n  await pushResource(\n    workspace.workspaceId,\n    remotePath,\n    undefined,\n    parseFromFile(filePath),\n    filePath  // Pass the local file path for branch-specific inline content resolution\n  );\n  log.info(colors.bold.underline.green(`Resource ${remotePath} pushed`));\n}\n\nasync function list(opts: GlobalOptions & { json?: boolean }) {\n  if (opts.json) log.setSilent(true);\n  const workspace = await resolveWorkspace(opts);\n  await requireLogin(opts);","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/resource/resource.ts#L159-L195","documentation":"Thrown by the Windmill CLI's `resource push` command when the local path given to push does not point to a regular file on disk. After validating the remote path, the CLI calls stat(filePath) and requires the entry to be a file (isFile()); directories, sockets, symlinks-to-directories, or nonexistent paths fail (stat itself rejecting surfaces as ENOENT, but a directory hits this explicit error).","triggerScenarios":"Running `wmill resource push <remote> <localPath>` where localPath is a directory (e.g. passing the containing folder instead of the `.resource.yaml` file), or a special/non-regular file. Note: a nonexistent path throws from stat with ENOENT before reaching this check.","commonSituations":"Passing a directory by mistake or relying on shell glob expansion that yielded a directory; pointing at a symlink that resolves to a directory; scripting that interpolates an empty or wrong variable so the path ends up as '.' or a folder; copy-pasting a folder path instead of the resource YAML file.","solutions":["Pass the actual resource YAML file path (e.g. ./myres.resource.yaml) instead of a directory","If it's a symlink, point at or link the real file","Verify with `ls -l <path>` / `test -f <path>` that the argument is a regular file before pushing"],"exampleFix":"// before\nwmill resource push u/admin/myres ./resources/\n// after\nwmill resource push u/admin/myres ./resources/myres.resource.yaml","handlingStrategy":"validation","validationCode":"import { statSync } from 'fs';\n\nconst st = statSync(localPath); // throws ENOENT early if missing\nif (!st.isFile()) {\n  throw new Error(`--path must be a .resource.yaml file, got: ${localPath}`);\n}","typeGuard":"import { Stats, statSync } from 'fs';\n\nasync function isRegularFile(p: string): Promise<boolean> {\n  try { return (await import('fs/promises')).default.stat(p).then(s => s.isFile()); } catch { return false; }\n}\n// sync variant:\nfunction isFile(p: string): boolean { try { return statSync(p).isFile(); } catch { return false; } }","tryCatchPattern":"try {\n  await wmill.resource.push(remotePath, localPath);\n} catch (e) {\n  if ((e as Error).message === 'file path must refer to a file.') {\n    console.error(`${localPath} is a directory or not a regular file; pass the .resource.yaml file itself`);\n  } else throw e;\n}","preventionTips":["Pass the exact `.resource.yaml` file path, never its containing directory","Check paths with `test -f \"$path\"` in shell scripts before pushing","Beware symlinks: stat follows them; link to files, not directories","Let tab-completion finish at the file, and re-read the command before running"],"tags":["cli","windmill","filesystem","argument-validation"],"backgroundTag":"path-is-not-a-file","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"}