{"record":{"id":"ac7324df1dee2f60","repo":"dgraph-io/dgraph","slug":"invalid-bucket-q","errorCode":null,"errorMessage":"Invalid bucket: %q","messagePattern":"Invalid bucket: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"x/minioclient.go","lineNumber":88,"sourceCode":"\n\treturn &credentials.Chain{Providers: providers}\n}\n\nfunc requestCreds(creds *MinioCredentials) credentials.Value {\n\tif creds == nil {\n\t\treturn credentials.Value{}\n\t}\n\n\treturn credentials.Value{\n\t\tAccessKeyID:     creds.AccessKey,\n\t\tSecretAccessKey: string(creds.SecretKey),\n\t\tSessionToken:    string(creds.SessionToken),\n\t}\n}\n\nfunc NewMinioClient(uri *url.URL, creds *MinioCredentials) (*MinioClient, error) {\n\tif len(uri.Path) < 1 {\n\t\treturn nil, errors.Errorf(\"Invalid bucket: %q\", uri.Path)\n\t}\n\n\tglog.V(2).Infof(\"Backup/Export using host: %s, path: %s\", uri.Host, uri.Path)\n\n\t// Verify URI and set default S3 host if needed.\n\tswitch uri.Scheme {\n\tcase \"s3\":\n\t\t// s3:///bucket/folder\n\t\tif !strings.Contains(uri.Host, \".\") {\n\t\t\turi.Host = defaultEndpointS3\n\t\t}\n\tdefault: // minio\n\t\tif uri.Host == \"\" {\n\t\t\treturn nil, errors.Errorf(\"Minio handler requires a host\")\n\t\t}\n\t}\n\n\tsecure := uri.Query().Get(\"secure\") != \"false\" // secure by default","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/x/minioclient.go#L70-L106","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Append the bucket name to the URI path, e.g. s3://s3.amazonaws.com/my-bucket","Verify the configured endpoint/env var (e.g.backup target URL) includes the bucket after the host","Check for code that builds the url.URL and ensure u.Path is set before calling NewMinioClient"],"exampleFix":"// before\nu, _ := url.Parse(\"s3://s3.amazonaws.com\")\nclient, err := NewMinioClient(u, creds) // Invalid bucket: \"\"\n// after\nu, _ := url.Parse(\"s3://s3.amazonaws.com/my-bucket\")\nclient, err := NewMinioClient(u, creds)","handlingStrategy":"validation","validationCode":"u, err := url.Parse(rawURI)\nif err != nil { return err }\nif u.Path == \"\" || u.Path == \"/\" {\n    return fmt.Errorf(\"URI %q must include a bucket in the path, e.g. %s/my-bucket\", rawURI, u.Host)\n}","typeGuard":"func hasBucket(u *url.URL) bool { return u != nil && len(u.Path) >= 1 }","tryCatchPattern":null,"preventionTips":["Always include the bucket in backup/export target URIs","Add a config pre-check that parses the URI and asserts a non-empty path","Log the full URI (minus credentials) when constructing storage clients"],"tags":["s3","minio","configuration","bucket"],"backgroundTag":"invalid-s3-bucket-uri","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}