{"record":{"id":"8f4fb29c98e5effb","repo":"juicedata/juicefs","slug":"create-b2-client-s","errorCode":null,"errorMessage":"create B2 client: %s","messagePattern":"create B2 client: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/b2.go","lineNumber":173,"sourceCode":"// TODO: support multipart upload using S3 client\n\nfunc newB2(endpoint, keyID, applicationKey, token string) (ObjectStorage, error) {\n\tif !strings.Contains(endpoint, \"://\") {\n\t\tendpoint = fmt.Sprintf(\"https://%s\", endpoint)\n\t}\n\turi, err := url.ParseRequestURI(endpoint)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Invalid endpoint: %v, error: %v\", endpoint, err)\n\t}\n\thostParts := strings.Split(uri.Host, \".\")\n\tname := hostParts[0]\n\t// TODO: set UserAgent once kothar/go-backblaze supports http.Client injection\n\tclient, err := backblaze.NewB2(backblaze.Credentials{\n\t\tKeyID:          keyID,\n\t\tApplicationKey: applicationKey,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create B2 client: %s\", err)\n\t}\n\tclient.MaxIdleUploads = 20\n\tbucket, err := client.Bucket(name)\n\tif err != nil {\n\t\tlogger.Warnf(\"access bucket %s: %s\", name, err)\n\t}\n\tif err == nil && bucket == nil {\n\t\tbucket, err = client.CreateBucket(name, \"allPrivate\")\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"create bucket %s: %s\", name, err)\n\t\t}\n\t}\n\tif bucket == nil {\n\t\treturn nil, fmt.Errorf(\"can't find bucket %s with provided Key ID\", name)\n\t}\n\treturn &b2client{bucket: bucket}, nil\n}\n","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/b2.go#L155-L191","documentation":"Constructing the Backblaze B2 SDK client (backblaze.NewB2) failed while initializing a B2 object storage backend. Wraps the SDK error, which typically indicates invalid or missing keyID/applicationKey credentials or an unreachable B2 API endpoint during authorization.","triggerScenarios":"newB2 with an application key ID or master/application key that is wrong, disabled, or revoked; network failure reaching the Backblaze auth endpoint.","commonSituations":"Swapped keyID/applicationKey; key deleted from Backblaze console; typo when pasting keys; corporate proxy blocking api.backblazeb2.com.","solutions":["Verify keyID and applicationKey in the Backblaze B2 console / b2 CLI ('b2 authorize-account').","Regenerate the application key if it was deleted or rotated.","Confirm network access to api.backblazeb2.com.","Check that keyID and applicationKey are not swapped in configuration."],"exampleFix":"// before\nkeyID: \"abcd\", applicationKey: \"00112233\"   (wrong key)\n// after\nkeyID: \"003aabbccddefff0000000001\", applicationKey: \"K001validkey...\"","handlingStrategy":"try-catch","validationCode":"if keyID == \"\" || applicationKey == \"\" { return errors.New(\"B2 keyID and applicationKey are required\") }","typeGuard":null,"tryCatchPattern":"client, err := backblaze.NewB2(backblaze.Credentials{KeyID: keyID, ApplicationKey: applicationKey})\nif err != nil {\n    return fmt.Errorf(\"B2 authorization failed (check keyID/applicationKey and network): %w\", err)\n}","preventionTips":["Verify keys with 'b2 authorize-account' before deploying","Rotate keys via the B2 console and update config atomically","Confirm api.backblazeb2.com is reachable from the environment"],"tags":["b2","authentication","credentials","object-storage"],"backgroundTag":"authentication-required","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}