dgraph-io/dgraph · error

Invalid bucket: %q

Error message

Invalid bucket: %q

What it means

NewMinioClient validates that the S3/Minio URI has a non-empty path component before constructing the client. The path after the scheme/host is interpreted as the bucket name, so an empty path means no bucket was specified and the client cannot be created. This is a fail-fast configuration validation error.

Source

Thrown at x/minioclient.go:88

	return &credentials.Chain{Providers: providers}
}

func requestCreds(creds *MinioCredentials) credentials.Value {
	if creds == nil {
		return credentials.Value{}
	}

	return credentials.Value{
		AccessKeyID:     creds.AccessKey,
		SecretAccessKey: string(creds.SecretKey),
		SessionToken:    string(creds.SessionToken),
	}
}

func NewMinioClient(uri *url.URL, creds *MinioCredentials) (*MinioClient, error) {
	if len(uri.Path) < 1 {
		return nil, errors.Errorf("Invalid bucket: %q", uri.Path)
	}

	glog.V(2).Infof("Backup/Export using host: %s, path: %s", uri.Host, uri.Path)

	// Verify URI and set default S3 host if needed.
	switch uri.Scheme {
	case "s3":
		// s3:///bucket/folder
		if !strings.Contains(uri.Host, ".") {
			uri.Host = defaultEndpointS3
		}
	default: // minio
		if uri.Host == "" {
			return nil, errors.Errorf("Minio handler requires a host")
		}
	}

	secure := uri.Query().Get("secure") != "false" // secure by default

View on GitHub (pinned to 759e242be6)

Solutions

  1. Append the bucket name to the URI path, e.g. s3://s3.amazonaws.com/my-bucket
  2. Verify the configured endpoint/env var (e.g.backup target URL) includes the bucket after the host
  3. Check for code that builds the url.URL and ensure u.Path is set before calling NewMinioClient

Example fix

// before
u, _ := url.Parse("s3://s3.amazonaws.com")
client, err := NewMinioClient(u, creds) // Invalid bucket: ""
// after
u, _ := url.Parse("s3://s3.amazonaws.com/my-bucket")
client, err := NewMinioClient(u, creds)
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(rawURI)
if err != nil { return err }
if u.Path == "" || u.Path == "/" {
    return fmt.Errorf("URI %q must include a bucket in the path, e.g. %s/my-bucket", rawURI, u.Host)
}

Type guard

func hasBucket(u *url.URL) bool { return u != nil && len(u.Path) >= 1 }

Prevention

When it happens

Trigger: Calling NewMinioClient (directly or via NewFileStore, NewS3Handler, or newRemoteExportStorage) with a *url.URL whose Path is empty — e.g. 's3://' or 'https://s3.amazonaws.com' with no bucket in the URI.

Common situations: Backup/export target URIs configured without a bucket ('s3://backups.example.com' instead of 's3://backups.example.com/bucket'), env vars or CLI flags where the bucket portion was dropped, or string-splitting on '/' that loses the bucket segment.

Related errors


AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01). Data as JSON: /api/errors/ac7324df1dee2f60. Report an issue: GitHub.