larksuite/cli · error

%s: cannot stat %q: %w

Error message

%s: cannot stat %q: %w

What it means

On Windows, auditFilePermissions skips POSIX bit checks (Go's mode bits derive from file attributes, not NTFS ACLs) and only verifies the path exists via vfs.Stat. If the stat fails, the stat error is wrapped with the audit label and path so the caller knows which file could not be verified.

Source

Thrown at internal/binding/audit_windows.go:23

package binding

import (
	"fmt"

	"github.com/larksuite/cli/internal/vfs"
)

// checkOwnerUID is a no-op on Windows where Unix UID semantics don't apply.
func checkOwnerUID(path, label string) error {
	return nil
}

// auditFilePermissions skips POSIX permission-bit auditing on Windows because
// Go synthesizes mode bits from file attributes rather than NTFS ACLs.
func auditFilePermissions(effectivePath string, allowReadableByOthers bool, label string) error {
	if _, err := vfs.Stat(effectivePath); err != nil {
		return fmt.Errorf("%s: cannot stat %q: %w", label, effectivePath, err)
	}
	return nil
}

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Verify the path exists: `dir <path>` / `Test-Path <path>`
  2. Correct the path in the config that references the secret file
  3. Grant the current user read access to the file/directory
  4. Use a UNC/absolute path within MAX_PATH limits

Example fix

// before
secret: {"source":"file","path":"C:/secrets/app.key"}   // file missing
// after
copy C:/secrets/backup.key C:/secrets/app.key   # then retry
Defensive patterns

Strategy: validation

Validate before calling

if _, err := os.Stat(secretPath); err != nil {
    return fmt.Errorf("secret file %q unavailable: %w", secretPath, err)
}

Try / catch

err := cmd.Run()
var pathErr *os.PathError
if errors.As(err, &pathErr) {
    // pathErr.Path names the file; recreate or fix the reference
}

Prevention

When it happens

Trigger: auditFilePermissions is called with effectivePath that does not exist, the process lacks access to it, the path is too long/malformed, or it sits on an unavailable network drive.

Common situations: Typo in the secret file path in ~/.lark-channel/config.json; file deleted after config referenced it; permission-protected directory; path containing invalid characters or exceeding MAX_PATH.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/a16bca69038c5869. Report an issue: GitHub.