larksuite/cli · error
%s: cannot retrieve file owner for %q
Error message
%s: cannot retrieve file owner for %q
What it means
After stat succeeds, checkOwnerUID extracts the raw syscall.Stat_t via stat.Sys() to read the owner UID. On platforms or filesystems where the syscall-specific stat structure is unavailable, the type assertion fails and this error is thrown. It is a defensive guard: without owner information the security audit cannot proceed safely, so it fails closed.
Source
Thrown at internal/binding/audit_unix.go:24
package binding
import (
"fmt"
"os"
"syscall"
"github.com/larksuite/cli/internal/vfs"
)
// checkOwnerUID verifies the file is owned by the current user.
func checkOwnerUID(path, label string) error {
stat, err := vfs.Stat(path)
if err != nil {
return fmt.Errorf("%s: cannot stat %q: %w", label, path, err)
}
sysStat, ok := stat.Sys().(*syscall.Stat_t)
if !ok {
return fmt.Errorf("%s: cannot retrieve file owner for %q", label, path)
}
if sysStat.Uid != uint32(os.Getuid()) {
return fmt.Errorf("%s: path %q is owned by uid %d, expected %d",
label, path, sysStat.Uid, os.Getuid())
}
return nil
}
// auditFilePermissions rejects world/group-writable modes (always) and
// world/group-readable modes (unless allowReadableByOthers is true, which
// exec commands typically need for their usual 755 mode).
func auditFilePermissions(effectivePath string, allowReadableByOthers bool, label string) error {
info, err := vfs.Stat(effectivePath)
if err != nil {
return fmt.Errorf("%s: cannot stat %q: %w", label, effectivePath, err)
}
mode := info.Mode().Perm()
View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Run the CLI on a supported Unix platform (Linux/macOS) with a standard filesystem
- Ensure the file lives on a regular local filesystem, not a shim that hides syscall metadata
- If you maintain a custom vfs backend, return the platform's real *syscall.Stat_t from Sys()
- Report the platform combination to the maintainers if it should be supported
Defensive patterns
Strategy: type-guard
Validate before calling
if fi, err := os.Stat(path); err == nil {
if _, ok := fi.Sys().(*syscall.Stat_t); !ok {
return fmt.Errorf("platform cannot expose owner uid for %s", path)
}
} Type guard
func hasSysStat(fi fs.FileInfo) (*syscall.Stat_t, bool) {
st, ok := fi.Sys().(*syscall.Stat_t)
return st, ok
} Prevention
- Run the CLI on supported Unix platforms with standard filesystems
- Avoid exotic FUSE/shim filesystems for audited files
- Test on the target platform before deploying configs
When it happens
Trigger: stat.Sys() does not return *syscall.Stat_t — practically only on non-Unix builds that still compile this file (it is guarded by !windows, so this indicates an exotic platform) or a vfs implementation returning a synthetic FileInfo without a real syscall backing.
Common situations: Running on an unusual/unsupported Unix-like platform; a vfs layer that fabricates FileInfo (e.g. tests, FUSE-like shims) without a real Stat_t; cross-compiled binary running under an emulation layer with incomplete stat support.
Related errors
- %s: cannot stat %q: %w
- %s: cannot stat %q: %w
- %s: cannot resolve symlink %q: %w
- %s: cannot stat resolved path %q: %w
- %s: resolved path %q is still a symlink
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/350b878bf6312cbc.
Report an issue: GitHub.