{"record":{"id":"7d79b34e7ead24e9","repo":"kubernetes/kops","slug":"error-getting-file-stat-for-q-v","errorCode":null,"errorMessage":"error getting file stat for %q: %v","messagePattern":"error getting file stat for %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/files_owner.go","lineNumber":35,"sourceCode":"*/\n\npackage fi\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"syscall\"\n\n\t\"k8s.io/klog/v2\"\n)\n\n// EnsureFileOwner will set the owner & group for a file.\n// Empty values for owner/group will leave the owner/group unchanged.\nfunc EnsureFileOwner(destPath string, owner string, groupName string) (bool, error) {\n\tchanged := false\n\tstat, err := os.Lstat(destPath)\n\tif err != nil {\n\t\treturn changed, fmt.Errorf(\"error getting file stat for %q: %v\", destPath, err)\n\t}\n\n\tactualUserID := int(stat.Sys().(*syscall.Stat_t).Uid)\n\tuserID := actualUserID\n\tif owner != \"\" {\n\t\tuser, err := LookupUser(owner) // user.Lookup(owner)\n\t\tif err != nil {\n\t\t\treturn changed, fmt.Errorf(\"error looking up user %q: %v\", owner, err)\n\t\t}\n\t\tif user == nil {\n\t\t\treturn changed, fmt.Errorf(\"user %q not found\", owner)\n\t\t}\n\t\tuserID = user.Uid\n\t}\n\n\tactualGroupID := int(stat.Sys().(*syscall.Stat_t).Gid)\n\tgroupID := actualGroupID\n\tif groupName != \"\" {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/files_owner.go#L17-L53","documentation":"Thrown by EnsureFileOwner when os.Lstat fails on the file whose owner/group should be enforced. The file is missing at check time (removed or not yet created), a path component is a broken symlink, or a parent directory denies search permission so stat cannot traverse.","triggerScenarios":"Thrown at upup/pkg/fi/files_owner.go:35 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the file exists when the owner check runs; add task dependencies if it is written later","Fix broken symlinks on the path","Ensure the running user can traverse (execute bit) all parent directories"],"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"}