Billionmail/BillionMail · error
invalid attr:
Error message
invalid attr:
What it means
ChattrRecursive accepts an attribute string of exactly two characters: a sign ('+' or '-') followed by one of i, a, d, s, c. Anything of the wrong length, wrong sign, or unsupported flag returns "invalid attr: <attr>" before any filesystem access.
Source
Thrown at core/internal/service/public/common.go:1567
if err != nil {
return err
}
}
}
return os.Chmod(path, mode)
}
// Change file or directory attributes
func Chattr(path string, attr string) error {
return ChattrRecursive(path, attr)
}
// Change file or directory attributes (recursive)
func ChattrRecursive(path string, attr string) error {
// Check if attr is valid
if len(attr) != 2 || (attr[0] != '+' && attr[0] != '-') {
return errors.New("invalid attr: " + attr)
}
if attr[1] != 'i' && attr[1] != 'a' && attr[1] != 'd' && attr[1] != 's' && attr[1] != 'c' {
return errors.New("invalid attr: " + attr)
}
// File does not exist
if !FileExists(path) {
return errors.New("file not exists: " + path)
}
// Directory
if IsDir(path) {
ds, err := os.ReadDir(path)
if err != nil {
return err
}View on GitHub (pinned to fc36c76c05)
Solutions
- Pass a two-character string: sign plus one of i/a/d/s/c (e.g. "+i", "-a")
- Validate the attr with a whitelist before calling
- Map unsupported chattr CLI flags to the supported set or drop them
Example fix
// before
public.ChattrRecursive(path, flag) // flag = "i" -> invalid attr
// after
sign := "+"
if remove { sign = "-" }
public.ChattrRecursive(path, sign+flag) // e.g. "+i"
Defensive patterns
Strategy: validation
Validate before calling
func checkAttrFormat(attr string) error {
if len(attr) != 2 || (attr[0] != '+' && attr[0] != '-') {
return fmt.Errorf("attr must start with + or -: %q", attr)
}
return nil
} Type guard
func hasAttrSign(s string) bool {
return len(s) == 2 && (s[0] == '+' || s[0] == '-')
} Try / catch
if err := public.Chattr(path, attr); err != nil {
if strings.Contains(err.Error(), "invalid attr") {
log.Errorf("bad attr %q from caller; expected e.g. '+i'", attr)
return nil
}
return err
} Prevention
- Always build attr as sign + single letter, never pass the bare letter
- Type-check config values that feed Chattr (string vs decoded YAML)
- Add unit tests covering '+i','-i','i','+x','','+ii'
When it happens
Trigger: Calling Chattr/ChattrRecursive with attr values like "i" (no sign), "+x" (unsupported flag), "+ii" (wrong length), "++i" (wrong sign), or an empty string.
Common situations: Building the attr string dynamically and dropping the sign; copying chattr CLI syntax with flags this wrapper does not support (e.g. '+u', '+e'); i18n/config files containing a single-letter flag.
Understand the failure class
Background: "must be a positive integer", "cannot be empty", "invalid argument": how invalid-argument errors work across open-source libraries — this error's family across 33 libraries.
Related errors
- unable to determine domain for noreply email
- failed to create email sender: %w
- failed to send confirmation email: %w
- unsupported file type: %s
- required column 'email' not found
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/2f202392fbee3566.
Report an issue: GitHub.