{"record":{"id":"d4a9b787da2d162b","repo":"kubernetes/kops","slug":"error-getting-file-mode-for-q-v","errorCode":null,"errorMessage":"error getting file mode for %q: %v","messagePattern":"error getting file mode for %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/files.go","lineNumber":112,"sourceCode":"\n\tif err := tempFile.Close(); err != nil {\n\t\treturn fmt.Errorf(\"error closing temp file %q: %w\", tempFile.Name(), err)\n\t}\n\tcloseTempFile = false\n\n\tif err := os.Rename(tempFile.Name(), destPath); err != nil {\n\t\treturn fmt.Errorf(\"error renaming temp file %q -> %q: %w\", tempFile.Name(), destPath, err)\n\t}\n\tdeleteTempFile = false\n\n\treturn nil\n}\n\nfunc EnsureFileMode(destPath string, fileMode os.FileMode) (bool, error) {\n\tchanged := false\n\tstat, err := os.Lstat(destPath)\n\tif err != nil {\n\t\treturn changed, fmt.Errorf(\"error getting file mode for %q: %v\", destPath, err)\n\t}\n\tif (stat.Mode() & os.ModePerm) == fileMode {\n\t\treturn changed, nil\n\t}\n\tklog.Infof(\"Changing file mode for %q to %s\", destPath, fileMode)\n\n\terr = os.Chmod(destPath, fileMode)\n\tif err != nil {\n\t\treturn changed, fmt.Errorf(\"error setting file mode for %q: %v\", destPath, err)\n\t}\n\tchanged = true\n\treturn changed, nil\n}\n\nfunc fileHasHash(f string, expected *hashing.Hash) (bool, error) {\n\tactual, err := expected.Algorithm.HashFile(f)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/files.go#L94-L130","documentation":"Thrown by EnsureFileMode when os.Lstat fails on the path whose mode should be verified/enforced. Usually means the file no longer exists at check time (deleted between write and check), the path traverses a bad symlink, or permissions block stat on a parent directory.","triggerScenarios":"Thrown at upup/pkg/fi/files.go:112 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the file exists at the given path at the time of the check","Check for broken symlinks or permission-restricted parent directories","If the file is created later by another task, ensure this task runs after it (add a dependency)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}