Tencent/WeKnora · error

failed to create bucket: %w

Error message

failed to create bucket: %w

What it means

MinIO service constructor: the configured bucket was found missing and MakeBucket failed while trying to create it, so the file service cannot initialize and construction aborts with the wrapped cause.

Source

Thrown at internal/application/service/file/minio.go:64

}

// NewMinioFileService creates a MinIO file service.
// It verifies that the bucket exists and creates it if missing.
func NewMinioFileService(endpoint,
	accessKeyID, secretAccessKey, bucketName string, useSSL bool,
) (interfaces.FileService, error) {
	svc, err := newMinioClient(endpoint, accessKeyID, secretAccessKey, bucketName, useSSL)
	if err != nil {
		return nil, err
	}

	exists, err := svc.client.BucketExists(context.Background(), bucketName)
	if err != nil {
		return nil, fmt.Errorf("failed to check bucket: %w", err)
	}
	if !exists {
		if err = svc.client.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{}); err != nil {
			return nil, fmt.Errorf("failed to create bucket: %w", err)
		}
	}

	return svc, nil
}

// CheckConnectivity verifies MinIO is reachable and, if a bucket is configured,
// that the bucket exists. This is a read-only probe — it never creates a bucket.
func (s *minioFileService) CheckConnectivity(ctx context.Context) error {
	checkCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
	defer cancel()

	if s.bucketName != "" {
		exists, err := s.client.BucketExists(checkCtx, s.bucketName)
		if err != nil {
			return err
		}
		if !exists {

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Check MinIO credentials have bucket-creation permission
  2. Pre-create the bucket manually and retry initialization
  3. Inspect the wrapped error for policy/limits on the MinIO server
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/application/service/file/minio.go:64 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/787c1a33e8cb2138. Report an issue: GitHub.