weaviate/weaviate · error

failed to create file: %w

Error message

failed to create file: %w

What it means

os.Create failed while creating the dynamic-users storage file during createStorage — the directory existed (or was created) but the file itself could not be created. Wrapped error has the OS cause: permission denied, name too long, or read-only filesystem. Only fires when the file does not already exist (existing files pass through).

Source

Thrown at usecases/auth/authentication/apikey/db_users.go:999

	c.lock.Lock()
	defer c.lock.Unlock()
	return c.storeToFile()
}

func createStorage(filePath string) error {
	if err := os.MkdirAll(filepath.Dir(filePath), os.ModePerm); err != nil {
		return fmt.Errorf("failed to create directories: %w", err)
	}

	_, err := os.Stat(filePath)
	if err == nil { // file exists
		return nil
	}

	if os.IsNotExist(err) {
		file, err := os.Create(filePath)
		if err != nil {
			return fmt.Errorf("failed to create file: %w", err)
		}
		defer file.Close()
		return nil
	}

	return err
}

func ReadFile(filename string) ([]byte, error) {
	file, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer file.Close()

	fileInfo, err := file.Stat()
	if err != nil {
		return nil, err

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Verify write permission on the directory for the db-users file name
  2. Ensure the filename (from configuration) contains no invalid characters
  3. Remount the filesystem read-write if read-only
  4. Check disk space and inode availability
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at usecases/auth/authentication/apikey/db_users.go:999 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/f39a4f4d7a4ab88e. Report an issue: GitHub.