{"record":{"id":"5856ecdd4c0fd11b","repo":"apache/hadoop","slug":"no-cos-credential-providers","errorCode":null,"errorMessage":"No COS Credential Providers","messagePattern":"No COS Credential Providers","errorType":"exception","errorClass":"NoAuthWithCOSException","httpStatus":null,"severity":"critical","filePath":"hadoop-cloud-storage-project/hadoop-cos/src/main/java/org/apache/hadoop/fs/cosn/auth/COSCredentialsProviderList.java","lineNumber":75,"sourceCode":"  public COSCredentialsProviderList() {\n  }\n\n  public COSCredentialsProviderList(\n      Collection<COSCredentialsProvider> providers) {\n    this.providers.addAll(providers);\n  }\n\n  public void add(COSCredentialsProvider provider) {\n    this.providers.add(provider);\n  }\n\n  public int getRefCount() {\n    return this.refCount.get();\n  }\n\n  public void checkNotEmpty() {\n    if (this.providers.isEmpty()) {\n      throw new NoAuthWithCOSException(NO_COS_CREDENTIAL_PROVIDERS);\n    }\n  }\n\n  public COSCredentialsProviderList share() {\n    Preconditions.checkState(!this.closed(), \"Provider list is closed\");\n    this.refCount.incrementAndGet();\n    return this;\n  }\n\n  public boolean closed() {\n    return this.isClosed.get();\n  }\n\n  @Override\n  public COSCredentials getCredentials() {\n    if (this.closed()) {\n      throw new NoAuthWithCOSException(CREDENTIALS_REQUESTED_WHEN_CLOSED);\n    }","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-cos/src/main/java/org/apache/hadoop/fs/cosn/auth/COSCredentialsProviderList.java#L57-L93","documentation":"COSCredentialsProviderList is the refcounted chain of COSCredentialsProvider objects used by the cosn connector. checkNotEmpty() throws NoAuthWithCOSException(\"No COS Credential Providers\") when the chain contains zero providers — authentication was never configured, so any credential lookup fails fast. This is a configuration error surfaced the moment the filesystem tries to authenticate.","triggerScenarios":"Initializing a CosNFileSystem with fs.cosn.credentials.provider unset/empty, or configured with class names that all failed to load, leaving the provider list empty. checkNotEmpty() runs at the start of getCredentials(), so the first authenticated SDK call triggers it.","commonSituations":"core-site.xml missing the fs.cosn.credentials.provider property; a typo in a provider class name so instantiation of every listed provider fails; constructing the provider list programmatically and forgetting to add() before use.","solutions":["Set fs.cosn.credentials.provider in core-site.xml to a valid chain, e.g. org.apache.hadoop.fs.cosn.auth.SimpleCosCredentialsProvider (and/or EnvironmentVariableCredentialsProvider, CvmRoleCredentialsProvider on CVM)","Provide the corresponding secrets: fs.cosn.userinfo.secretId / fs.cosn.userinfo.secretKey for the simple provider, or COS_SECRETID/COS_SECRETKEY env vars","Verify provider class names against the hadoop-cos version in use (package org.apache.hadoop.fs.cosn.auth)"],"exampleFix":"// before\n// core-site.xml has no cosn credential config\n// -> NoAuthWithCOSException: No COS Credential Providers\n\n// after\n<property>\n  <name>fs.cosn.credentials.provider</name>\n  <value>org.apache.hadoop.fs.cosn.auth.SimpleCosCredentialsProvider</value>\n</property>\n<property>\n  <name>fs.cosn.userinfo.secretId</name><value>...</value>\n</property>\n<property>\n  <name>fs.cosn.userinfo.secretKey</name><value>...</value>\n</property>","handlingStrategy":"validation","validationCode":"// Fail fast at startup instead of at first authenticated call\nConfiguration conf = new Configuration();\nString chain = conf.get(\"fs.cosn.credentials.provider\");\nif (chain == null || chain.trim().isEmpty()) {\n  throw new IllegalArgumentException(\"fs.cosn.credentials.provider must be configured\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  fs.initialize(uri, conf);\n} catch (NoAuthWithCOSException e) {\n  if (String.valueOf(e.getMessage()).contains(\"No COS Credential Providers\")) {\n    // configuration error, not transient — fix fs.cosn.credentials.provider\n    throw new IllegalStateException(\"cosn credentials not configured\", e);\n  }\n  throw e;\n}","preventionTips":["Always set fs.cosn.credentials.provider plus the matching secret sources in core-site.xml","Add a startup config check so jobs fail before launch, not mid-run","Validate provider class names against the hadoop-cos version in use"],"tags":["cosn","hadoop-cos","authentication","credentials","configuration"],"backgroundTag":"missing-credentials-provider","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}