{"record":{"id":"51d8cdf15426f6ba","repo":"dgraph-io/dgraph","slug":"minio-handler-requires-a-host","errorCode":null,"errorMessage":"Minio handler requires a host","messagePattern":"Minio handler requires a host","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"x/minioclient.go","lineNumber":102,"sourceCode":"}\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\n\n\tif creds.isAnonymous() {\n\t\tmc, err := minio.New(uri.Host, &minio.Options{Secure: secure})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &MinioClient{mc}, nil\n\t}\n\n\tvar credsProvider *credentials.Credentials\n\tif Config.SharedInstance {\n\t\tcredsProvider = credentials.New(MinioCredentialsProviderWithoutEnv(requestCreds(creds)))\n\t} else {\n\t\tcredsProvider = credentials.New(MinioCredentialsProvider(uri.Scheme, requestCreds(creds)))","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/x/minioclient.go#L84-L120","documentation":"In the 'minio' scheme branch, NewMinioClient requires a host in the URI because Minio deployments are self-hosted and there is no default endpoint (unlike Amazon S3). An empty host means the client would not know which server to connect to, so construction fails immediately.","triggerScenarios":"Calling NewMinioClient (directly or via NewFileStore, NewS3Handler, newRemoteExportStorage) with a minio URI with empty host and a non-'s3' scheme, e.g. 'minio:///mybucket' or 'http:///bucket'.","commonSituations":"Minio endpoint config missing the host part ('minio://bucket' instead of 'minio://minio-host:9000/bucket'), a truncated URL in a config file, or DNS/proxy setups where the host was stripped during URL parsing.","solutions":["Include the Minio server host in the URI, e.g. minio://minio.example.com:9000/mybucket","Check the endpoint configuration/env var for a missing or truncated host","If you actually mean Amazon S3, use the s3 scheme so defaultEndpointS3 is applied"],"exampleFix":"// before\nu, _ := url.Parse(\"minio:///backups\") // no host\nclient, err := NewMinioClient(u, creds)\n// after\nu, _ := url.Parse(\"minio://minio.internal:9000/backups\")\nclient, err := NewMinioClient(u, creds)","handlingStrategy":"validation","validationCode":"u, err := url.Parse(rawURI)\nif err != nil { return err }\nif u.Scheme != \"s3\" && u.Host == \"\" {\n    return fmt.Errorf(\"minio endpoint requires a host: %q\", rawURI)\n}","typeGuard":"func hasHost(u *url.URL) bool { return u != nil && (u.Scheme == \"s3\" || u.Host != \"\") }","tryCatchPattern":null,"preventionTips":["Use the s3 scheme only for real Amazon S3 endpoints; self-hosted Minio must carry its host","Validate endpoint env/config at startup, before storage clients are built","Include host and port (e.g. minio.internal:9000) in connection strings"],"tags":["s3","minio","configuration","hostname"],"backgroundTag":"missing-endpoint-host","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}