Billionmail/BillionMail · error

file not exists:

Error message

file not exists: 

What it means

ChgrpWithGidRecursive recursively changes the group ownership of a path to the given GID. Before touching the filesystem it checks FileExists(path); if the path does not exist it returns "file not exists: <path>". The library throws this so callers get a clear pre-condition failure instead of an opaque os.Chown ENOENT error.

Source

Thrown at core/internal/service/public/common.go:1437

	if err != nil {
		return err
	}

	gid := gconv.Int(grp.Gid)

	if gid < 1 {
		return errors.New("group not exists: " + groupName)
	}

	return ChgrpWithGidRecursive(path, gid)
}

// Change group of a file or directory with GID (recursive)
func ChgrpWithGidRecursive(path string, gid int) error {
	// 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
		}

		for _, d := range ds {
			err = ChgrpWithGidRecursive(path+"/"+d.Name(), gid)

			if err != nil {
				return err
			}
		}
	}

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Verify the path exists with os.Stat or FileExists before calling
  2. Log/print the absolute path (filepath.Abs) to spot typos and wrong working directories
  3. Create the target path (os.MkdirAll) if it is expected to exist
  4. Check mounts/volumes if the path is normally provided by a container or NFS

Example fix

// before
if err := public.ChgrpWithGidRecursive(path, gid); err != nil { return err }
// after
if !public.FileExists(path) {
    return fmt.Errorf("skip chgrp, path missing: %s", path)
}
if err := public.ChgrpWithGidRecursive(path, gid); err != nil { return err }
Defensive patterns

Strategy: validation

Validate before calling

func canChgrp(path string) bool {
    _, err := os.Stat(path)
    return err == nil
}
if !canChgrp(path) { return fmt.Errorf("path missing: %s", path) }

Type guard

func pathExists(p string) bool {
    _, err := os.Stat(p)
    return !os.IsNotExist(err)
}

Try / catch

if err := public.ChgrpWithGidRecursive(path, gid); err != nil {
    if strings.HasPrefix(err.Error(), "file not exists") {
        log.Warnf("skipping chgrp, missing path: %s", path)
        return nil
    }
    return err
}

Prevention

When it happens

Trigger: Calling ChgrpWithGidRecursive(path, gid) with a path that has been deleted, renamed, is a broken symlink, or was never created (typo in path or missing mount).

Common situations: Deleting a user's mail directory while a background job still tries to chgrp it; relative path computed against a different working directory; container volume not mounted; typo in configured directory name.

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 Billionmail/BillionMail@fc36c76c05 (2026-09-05). Data as JSON: /api/errors/70cadeddb9f0fce7. Report an issue: GitHub.