alibaba/open-code-review · warning
chmod config: %w
Error message
chmod config: %w
What it means
After writing the config file, saveConfig calls os.Chmod(path, 0o600) to guarantee owner-only permissions on systems where umask may have relaxed them; failure is wrapped as "chmod config". The file is already written successfully at this point, so this is a hardening step, not a data-integrity failure.
Source
Thrown at cmd/opencodereview/provider_cmd.go:432
fmt.Printf("\nModel set to: %s\n", selectedModel)
return nil
}
func saveConfig(path string, cfg *Config) error {
dir := filepath.Dir(path)
if err := os.MkdirAll(dir, 0o755); err != nil {
return fmt.Errorf("create config dir: %w", err)
}
data, err := json.MarshalIndent(cfg, "", " ")
if err != nil {
return fmt.Errorf("marshal config: %w", err)
}
if err := os.WriteFile(path, data, 0o600); err != nil {
return fmt.Errorf("write config: %w", err)
}
if err := os.Chmod(path, 0o600); err != nil {
return fmt.Errorf("chmod config: %w", err)
}
return nil
}
func maskKey(key string) string {
if key == "" {
return "(not set)"
}
if len(key) <= 8 {
return "***"
}
return key[:4] + "***" + key[len(key)-4:]
}
// validateBaseURL checks that a provider Base URL has an http or https scheme
// and a non-empty host, giving the user immediate feedback rather than
// a runtime failure when the LLM client tries to use it.
func validateBaseURL(raw string) error {View on GitHub (pinned to 5cf97d0d15)
Solutions
- Verify the config file exists and is owned by the current user
- Move the config to a local POSIX filesystem that supports chmod
- If the filesystem cannot support permissions, verify the file already has 0600 via its mount options and treat this as environmental
- Check the wrapped inner error for the exact errno
Example fix
// before: config on an exFAT mount OCR_CONFIG=/mnt/usb/ocr/config.json ocr config set provider openai // error: chmod config: ... operation not supported // after OCR_CONFIG=~/.config/ocr/config.json ocr config set provider openai
Defensive patterns
Strategy: try-catch
Validate before calling
// verify chmod is supported on the target volume before saving
if err := os.Chmod(path, 0o600); err != nil {
fmt.Fprintf(os.Stderr, "warning: cannot enforce 0600 on %s: %v\n", path, err)
} Try / catch
if err := saveConfig(path, cfg); err != nil {
if strings.Contains(err.Error(), "chmod config") {
fmt.Fprintln(os.Stderr, "config saved but permissions could not be tightened; move config to a local POSIX filesystem")
return nil
}
return err
} Prevention
- Store config on a local POSIX filesystem rather than network/exFAT mounts
- Verify the saved file is 0600 after writes when handling secrets (API keys)
- Check mount options if chmod consistently fails
When it happens
Trigger: os.Chmod fails after a successful write — typically on filesystems that do not support permission changes (some network mounts, FAT/exFAT, certain Windows configurations) or when ownership changed mid-operation.
Common situations: Config stored on an NFS/SMB share or a Windows drive where chmod is unsupported or returns an error; container volumes mounted with restrictive options.
Related errors
- load config: %w
- create config dir: %w
- write config: %w
- read global rule %s: %w
- resolve project rule %s: %w
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/ccc44722133ea84f.
Report an issue: GitHub.