{"record":{"id":"61be6548891fe273","repo":"risingwavelabs/risingwave","slug":"invalid-collection-name","errorCode":null,"errorMessage":"invalid collection.name {}","messagePattern":"invalid collection\\.name (.+?)","errorType":"validation","errorClass":"SinkError::Config","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/mongodb.rs","lineNumber":314,"sourceCode":"            // but if the sink's pk is (_id, b) and the data will be:\n            // { \"_id\": {\"_id\": 1, \"b\": 2}, \"b\": 2, ... }\n            // in this case, the original _id field of the compound pk has been overridden\n            // we should consider this is a schema error\n            if self.pk_indices.len() > 1\n                && self\n                    .pk_indices\n                    .iter()\n                    .map(|&idx| self.schema.fields[idx].name.as_str())\n                    .any(|field| field == MONGODB_PK_NAME)\n            {\n                return Err(SinkError::Config(anyhow!(\n                    \"primary key fields must not contain a field named _id\"\n                )));\n            }\n        }\n\n        if let Err(err) = self.config.common.collection_name.parse::<Namespace>() {\n            return Err(SinkError::Config(anyhow!(err).context(format!(\n                \"invalid collection.name {}\",\n                self.config.common.collection_name\n            ))));\n        }\n\n        // checking reachability\n        let client = self.config.common.build_client().await?;\n        let client = ClientGuard::new(self.param.sink_name.clone(), client);\n        client\n            .database(\"admin\")\n            .run_command(doc! {\"hello\":1})\n            .await\n            .map_err(|err| {\n                SinkError::Mongodb(anyhow!(err).context(\"failed to send hello command to mongodb\"))\n            })?;\n\n        if self.config.drop_collection_name_field && self.config.collection_name_field.is_none() {\n            return Err(SinkError::Config(anyhow!(","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/mongodb.rs#L296-L332","documentation":"The `collection.name` option is parsed as a MongoDB `Namespace` (database.collection) to determine where documents are written. `validate` wraps any parse failure from `Namespace::from_str` with this context message, so an unparseable or malformed collection name fails sink creation. The original mongodb parse error is attached for details.","triggerScenarios":"CREATE SINK into mongodb where `collection.name` (e.g., option `collection`) is missing the `db.collection` form, contains invalid characters, or is empty.","commonSituations":"Providing only a collection name without the database prefix (or vice versa); typos or spaces in the option value; quoting/escaping issues in the WITH clause.","solutions":["Set collection.name in `database.collection` form, e.g. `collection='mydb.mycoll'` or use the separate database/collection options if available.","Remove invalid characters (spaces, dots beyond the single db/collection separator) from the value.","Check the wrapped mongodb error in the error chain for the exact parse reason."],"exampleFix":"-- before\nCREATE SINK s FROM mv INTO mongodb WITH (\n  connector='mongodb', url='mongodb://localhost:27017', collection='mycoll'\n);\n-- after\nCREATE SINK s FROM mv INTO mongodb WITH (\n  connector='mongodb', url='mongodb://localhost:27017', collection='mydb.mycoll'\n);","handlingStrategy":"validation","validationCode":"// collection must parse as db.collection\nconst parts = (sinkOptions.collection ?? \"\").split(\".\");\nif (parts.length !== 2 || parts.some(p => p.length === 0)) {\n  throw new Error(`collection must be in database.collection form: ${sinkOptions.collection}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use `database.collection` form in the collection option","Quote the value properly in the WITH clause","Pre-validate against a Namespace parser before submitting DDL"],"tags":["mongodb","sink","namespace","config"],"backgroundTag":"invalid-argument-format","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}