{"record":{"id":"48b5713506dd520b","repo":"larksuite/cli","slug":"cannot-determine-working-directory-w","errorCode":null,"errorMessage":"cannot determine working directory: %w","messagePattern":"cannot determine working directory: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/vfs/localfileio/path.go","lineNumber":87,"sourceCode":"\t}\n\tif err := validateLocalInputPlatform(path); err != nil {\n\t\treturn \"\", err\n\t}\n\tif err := denyCheckLocalInput(path); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn path, nil\n}\n\n// denyCheckLocalInput applies the built-in denylist to the relaxed local\n// input tier. Resolution is fail-closed like safePath, but the allowlist is\n// deliberately not consulted here. This tier hands the path back verbatim, so\n// every interpretation of it is checked — the caller opens the one the OS\n// picks, which for \"~/...\" is a literal \"~\" entry in the working directory.\nfunc denyCheckLocalInput(path string) error {\n\tcwd, err := vfs.Getwd()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot determine working directory: %w\", err)\n\t}\n\tinterps, err := interpretations(path, cwd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, abs := range interps {\n\t\tresolved, err := resolveReal(abs)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := checkDeny(\"local input path\", path, abs, resolved, cwd); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc isWindowsNonLocalNamespace(path string) bool {","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/vfs/localfileio/path.go#L69-L105","documentation":"denyCheckLocalInput resolves the path against the current working directory (fail-closed) before applying the built-in denylist. If the OS cannot report the working directory, the check cannot run and the function fails closed with this wrapped error rather than guessing a location.","triggerScenarios":"Calling localfileio.LocalInputPath (via denyCheckLocalInput) in a process whose cwd was deleted (e.g. the containing directory was removed while the process ran), or where vfs.Getwd fails due to permission loss on a path component.","commonSituations":"CI/container steps that rm -rf the directory a runner started in; a shell script that cds into a temp dir that a cleanup job deleted; running from a mounted volume that was unmounted.","solutions":["cd to a valid existing directory before running the command","Restart the process from an existing directory","In containers/CI, ensure cleanup steps don't delete the working directory the tool is invoked from"],"exampleFix":"// before (cwd deleted)\n$ lark apps upload --file data.json\n// error: cannot determine working directory: getwd: no such file or directory\n// after\n$ cd /tmp && lark apps upload --file /abs/path/data.json","handlingStrategy":"validation","validationCode":"if _, err := os.Getwd(); err != nil {\n    return fmt.Errorf(\"cwd unavailable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"p, err := localfileio.LocalInputPath(flagValue)\nif err != nil && strings.Contains(err.Error(), \"cannot determine working directory\") {\n    os.Chdir(\"/tmp\")\n    p, err = localfileio.LocalInputPath(flagValue)\n}","preventionTips":["Don't delete the directory a process is running from","Use absolute paths and a stable WORKDIR in CI","Verify cwd validity after cleanup steps in scripts"],"tags":["filesystem","working-directory","environment","fail-closed"],"backgroundTag":"working-directory-unavailable","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}