{"record":{"id":"b310e6a56ffe359e","repo":"slimtoolkit/slim","slug":"failed-to-get-system-stat-info-for-s","errorCode":null,"errorMessage":"failed to get system stat info for %s","messagePattern":"failed to get system stat info for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/sensor/artifact/artifact.go","lineNumber":3591,"sourceCode":"\t\t\tcontinue\n\t\t}\n\n\t\tinodes[info.Ino] = struct{}{}\n\t\tdevices[uint64(info.Dev)] = struct{}{}\n\t}\n\n\treturn inodes, devices\n}\n\nfunc getFileSysStats(fullName string) (*syscall.Stat_t, error) {\n\tstatInfo, err := os.Stat(fullName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tsysStatInfo, ok := statInfo.Sys().(*syscall.Stat_t)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"failed to get system stat info for %s\", fullName)\n\t}\n\n\treturn sysStatInfo, nil\n}\n\nfunc getFileDevice(fullName string) (uint64, error) {\n\tinfo, err := getFileSysStats(fullName)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn uint64(info.Dev), nil\n}\n","sourceCodeStart":3573,"sourceCodeEnd":3605,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/sensor/artifact/artifact.go#L3573-L3605","documentation":"A helper stats a file and then extracts the raw *syscall.Stat_t via FileInfo.Sys(). If the runtime type assertion fails, the caller cannot get device/inode info, so the function returns this error instead of a Stat_t. Like error 120 it only happens when Sys() is not a *syscall.Stat_t.","triggerScenarios":"Calling the helper (used by getFileDevice and artifact preparation) on a platform or filesystem where os.Lstat/stat returns a FileInfo whose Sys() is not *syscall.Stat_t.","commonSituations":"Running the sensor on darwin (Stat_t differs by GOOS build tags) or via overlay/FUSE layers; compiling with wrong GOOS.","solutions":["Run on Linux where Sys() is *syscall.Stat_t","Check err from the preceding stat call first and return it instead of falling through to the assertion","Skip or log-and-continue for files whose Sys() is not convertible"],"exampleFix":"// before\nsysStatInfo, ok := statInfo.Sys().(*syscall.Stat_t)\nif !ok {\n\treturn nil, fmt.Errorf(\"failed to get system stat info for %s\", fullName)\n}\n// after\nif statInfo == nil || statInfo.Sys() == nil {\n\treturn nil, fmt.Errorf(\"no stat info available for %s\", fullName)\n}\nsysStatInfo, ok := statInfo.Sys().(*syscall.Stat_t)\nif !ok {\n\treturn nil, fmt.Errorf(\"failed to get system stat info for %s\", fullName)\n}","handlingStrategy":"type-guard","validationCode":"fi, err := os.Stat(path)\nif err == nil {\n\tif _, ok := fi.Sys().(*syscall.Stat_t); !ok { /* unsupported platform/fs */ }\n}","typeGuard":"func statOf(fi os.FileInfo) (*syscall.Stat_t, bool) {\n\ts, ok := fi.Sys().(*syscall.Stat_t)\n\treturn s, ok\n}","tryCatchPattern":"_, err := getFileDevice(path)\nif err != nil && strings.Contains(err.Error(), \"failed to get system stat info\") {\n\t// fall back to a default device id or skip the file\n}","preventionTips":["Check the lstat err before relying on Sys()","Guard with runtime.GOOS checks before using syscall.Stat_t","Log and skip entries instead of aborting the whole scan"],"tags":["go","filesystem","type-assertion","stat"],"backgroundTag":"fileinfo-sys-type-assertion-failed","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}