{"record":{"id":"dfd20dcf37cfb8d5","repo":"juicedata/juicefs","slug":"fail-to-initialize-obs-q","errorCode":null,"errorMessage":"fail to initialize OBS: %q","messagePattern":"fail to initialize OBS: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/obs.go","lineNumber":434,"sourceCode":"\tif uri, err = url.ParseRequestURI(endpoint); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid endpoint %s: %q\", endpoint, err)\n\t}\n\tproxyURL, err := httpproxy.FromEnvironment().ProxyFunc()(uri)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get proxy url for endpoint: %s error: %q\", endpoint, err)\n\t}\n\tvar urlString string\n\tif proxyURL != nil {\n\t\turlString = proxyURL.String()\n\t}\n\n\t// Empty proxy url string has no effect\n\t// there is a bug in the retry of PUT (did not call Seek(0,0) before retry), so disable the retry here\n\tc, err := obs.New(accessKey, secretKey, endpoint, obs.WithSecurityToken(token),\n\t\tobs.WithProxyUrl(urlString), obs.WithMaxRetryCount(0), obs.WithUserAgent(UserAgent),\n\t\tobs.WithHttpTransport(httpClient.Transport.(*http.Transport)))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fail to initialize OBS: %q\", err)\n\t}\n\tvar checkEtag bool\n\tif _, err = c.GetBucketEncryption(bucketName); err != nil {\n\t\tif obsError, ok := err.(obs.ObsError); ok && obsError.Code == \"NoSuchEncryptionConfiguration\" {\n\t\t\tcheckEtag = true\n\t\t} else if !ok || obsError.Code != \"NoSuchBucket\" {\n\t\t\tlogger.Warnf(\"get bucket encryption: %q\", err)\n\t\t}\n\t}\n\treturn &obsClient{bucket: bucketName, region: region, checkEtag: checkEtag, c: c}, nil\n}\n\nfunc init() {\n\tRegister(\"obs\", newOBS)\n}\n","sourceCodeStart":416,"sourceCodeEnd":450,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/obs.go#L416-L450","documentation":"After endpoint and proxy setup, newOBS instantiates the Huawei OBS SDK client with obs.New. Any SDK-level initialization failure (bad credentials format, invalid config, transport issues) is wrapped as 'fail to initialize OBS: <err>'. Notably retry is disabled (WithMaxRetryCount(0)) because the SDK does not Seek(0,0) before PUT retries.","triggerScenarios":"obs.New returning an error for the given accessKey/secretKey/token/endpoint/transport — e.g. invalid security token, nil or incompatible http.Transport passed via WithHttpTransport, or SDK config validation failure.","commonSituations":"Empty or malformed access/secret keys; expired security token; custom transport not an *http.Transport (httpClient.Transport assertion assumptions); SDK version incompatibility.","solutions":["Read the wrapped %q error from the SDK for the exact cause","Verify access key, secret key, and security token are set and well-formed","Ensure the default http client transport is an *http.Transport (custom transports can break WithHttpTransport)","Try upgrading/downgrading the obs SDK dependency if init fails with valid inputs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if ak == \"\" || sk == \"\" { return errors.New(\"obs credentials required\") }\nif _, ok := httpClient.Transport.(*http.Transport); !ok { return errors.New(\"transport must be *http.Transport\") }","typeGuard":null,"tryCatchPattern":"store, err := object.CreateStorage(\"obs\", endpoint, ak, sk, token)\nif err != nil && strings.Contains(err.Error(), \"fail to initialize OBS\") {\n\t// inspect wrapped SDK error; fix credentials/token/transport\n}","preventionTips":["Validate credentials and token format before construction","Keep the default transport or ensure it is *http.Transport","Keep the obs SDK dependency updated"],"tags":["obs","sdk-init","credentials","huawei-cloud"],"backgroundTag":"module-init-failed","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"}