{"record":{"id":"44ae358bf6736e04","repo":"apache/seatunnel","slug":"azurecosmosdb-requires-key-primary-key-secondary","errorCode":null,"errorMessage":"AzureCosmosDB requires key, primary_key, secondary_key, or a connection string to resolve the key","messagePattern":"AzureCosmosDB requires key, primary_key, secondary_key, or a connection string to resolve the key","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-azurecosmosdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/azurecosmosdb/config/AzureCosmosDBConfig.java","lineNumber":72,"sourceCode":"        this.secondaryConnectionString =\n                config.getOptional(AzureCosmosDBSourceOptions.SECONDARY_CONNECTION_STRING)\n                        .orElse(null);\n        this.database = config.get(AzureCosmosDBSourceOptions.DATABASE);\n        this.container = config.get(AzureCosmosDBSourceOptions.CONTAINER);\n        this.query = config.get(AzureCosmosDBSourceOptions.QUERY);\n        this.maxItemCount = config.get(AzureCosmosDBSourceOptions.MAX_ITEM_COUNT);\n        this.schema =\n                config.getOptional(ConnectorCommonOptions.SCHEMA)\n                        .map(ReadonlyConfig::fromMap)\n                        .map(ReadonlyConfig::toConfig)\n                        .orElse(null);\n\n        if (getResolvedEndpoint() == null) {\n            throw new IllegalArgumentException(\n                    \"AzureCosmosDB requires uri, endpoint, or connection string to resolve the endpoint\");\n        }\n        if (getResolvedKey() == null) {\n            throw new IllegalArgumentException(\n                    \"AzureCosmosDB requires key, primary_key, secondary_key, or a connection string to resolve the key\");\n        }\n    }\n\n    public String getResolvedEndpoint() {\n        String resolvedEndpoint = firstNonBlank(uri, endpoint);\n        if (resolvedEndpoint != null) {\n            return resolvedEndpoint;\n        }\n\n        return firstNonBlank(\n                parseConnectionString(primaryConnectionString).get(\"endpoint\"),\n                parseConnectionString(secondaryConnectionString).get(\"endpoint\"));\n    }\n\n    public String getResolvedKey() {\n        String resolvedKey = firstNonBlank(key, primaryKey, secondaryKey);\n        if (resolvedKey != null) {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-azurecosmosdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/azurecosmosdb/config/AzureCosmosDBConfig.java#L54-L90","documentation":"AzureCosmosDBConfig validates that an authentication key can be resolved for the Cosmos DB account. The key comes from `key`, `primaryKey`, `secondaryKey`, or is parsed out of `connectionString`; if none is available it throws IllegalArgumentException at config construction.","triggerScenarios":"Building the connector config when none of `key`, `primary_key`, `secondary_key`, nor `connectionString` resolve to a non-blank value, even though an endpoint was resolved successfully.","commonSituations":"User set the uri but forgot the key; key stored only in an env var that was not set; using a connection string format the parser does not recognize; secret placeholder not substituted in a CI/K8s deployment.","solutions":["Set `key = \"<account primary or secondary key>\"` in the config","Or provide `primary_key` / `secondary_key` explicitly","Or provide a full `connectionString` so endpoint and key are both derived","Verify the secret is actually injected (env var, vault placeholder) and non-blank"],"exampleFix":"// before\nsink {\n  AzureCosmosDB {\n    uri = \"https://myaccount.documents.azure.com:443/\"\n    database = \"shop\"\n  }\n}\n// after\nsink {\n  AzureCosmosDB {\n    uri = \"https://myaccount.documents.azure.com:443/\"\n    key = \"${COSMOS_KEY}\"\n    database = \"shop\"\n  }\n}","handlingStrategy":"validation","validationCode":"boolean hasKey = cfg.getOptional(AzureCosmosDBConfig.KEY).isPresent()\n    || cfg.getOptional(AzureCosmosDBConfig.PRIMARY_KEY).isPresent()\n    || cfg.getOptional(AzureCosmosDBConfig.SECONDARY_KEY).isPresent()\n    || cfg.getOptional(AzureCosmosDBConfig.CONNECTION_STRING).isPresent();\nif (!hasKey) throw new IllegalArgumentException(\"Provide key, primary_key, secondary_key, or connectionString\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Store the key in an env var or secret store and reference it, never hardcode","Remember connectionString alone satisfies both endpoint and key requirements","Check secret injection (K8s secrets, CI placeholders) resolves to a non-blank value"],"tags":["config","azure-cosmosdb","authentication","missing-credentials"],"backgroundTag":"missing-credentials","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}