Billionmail/BillionMail · warning
open maildirsize failed: %w
Error message
open maildirsize failed: %w
What it means
readMaildirsize opens the 'maildirsize' file inside a user's maildir to compute used quota space; this error wraps any os.Open failure (missing file or permission denied) when updating a mailbox's used space. It means the used-space calculation could not read its data source for that user.
Source
Thrown at core/internal/service/mail_boxes/update_used_space.go:194
} else {
if err := tx.Commit(); err != nil {
failCount += len(batch)
} else {
successCount += batchSuccess
}
}
}
//g.Log().Debug(ctx, "Batch update completed", "success", successCount, "failed", failCount)
}
func readMaildirsize(userDir string) (int64, error) {
path := filepath.Join(userDir, "maildirsize")
f, err := os.Open(path)
if err != nil {
return 0, fmt.Errorf("open maildirsize failed: %w", err)
}
defer f.Close()
scanner := bufio.NewScanner(f)
var total int64
var lineNo int
for scanner.Scan() {
lineNo++
line := strings.TrimSpace(scanner.Text())
if line == "" || strings.HasPrefix(line, "#") {
continue
}
parts := strings.Fields(line)
if len(parts) == 0 {
continueView on GitHub (pinned to fc36c76c05)
Solutions
- Verify the user's maildir exists and contains a maildirsize file; send a test mail or let Dovecot initialize quotas
- Check file ownership/permissions so the BillionMail process can read the maildir
- Confirm the userDir path passed to readMaildirsize is correct for that mailbox
- Treat missing maildirsize as zero usage upstream if that is acceptable for your setup
Defensive patterns
Strategy: fallback
Validate before calling
if _, err := os.Stat(filepath.Join(userDir, "maildirsize")); os.IsNotExist(err) {
// maildir not initialized; treat used space as 0 or skip
} Try / catch
if err != nil && strings.Contains(err.Error(), "open maildirsize failed") {
if os.IsNotExist(errors.Unwrap(err)) {
// default used space to 0 and continue
}
} Prevention
- Ensure Dovecot initializes maildirsize for new mailboxes (send a welcome mail)
- Keep maildir ownership consistent with the app user
- Verify userDir path construction before quota updates
When it happens
Trigger: Calling the used-space update path (anonymous caller) for a user directory that has no maildirsize file, or one the process cannot read (wrong ownership/permissions).
Common situations: Mailbox created but never received mail (maildirsize not yet created by Dovecot); maildir mounted/copied with wrong ownership; user directory path computed incorrectly.
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
- parse maildirsize line %d: invalid size '%s': %w
- project configuration file does not exist: %s
- error reading project configuration file: %v
- error writing project configuration file: %v
- error creating project configuration: %v
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/e8305d1afe9ba920.
Report an issue: GitHub.