risingwavelabs/risingwave · error · SinkError::Config
invalid collection.name {}
Error message
invalid collection.name {} What it means
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.
Source
Thrown at src/connector/src/sink/mongodb.rs:314
// but if the sink's pk is (_id, b) and the data will be:
// { "_id": {"_id": 1, "b": 2}, "b": 2, ... }
// in this case, the original _id field of the compound pk has been overridden
// we should consider this is a schema error
if self.pk_indices.len() > 1
&& self
.pk_indices
.iter()
.map(|&idx| self.schema.fields[idx].name.as_str())
.any(|field| field == MONGODB_PK_NAME)
{
return Err(SinkError::Config(anyhow!(
"primary key fields must not contain a field named _id"
)));
}
}
if let Err(err) = self.config.common.collection_name.parse::<Namespace>() {
return Err(SinkError::Config(anyhow!(err).context(format!(
"invalid collection.name {}",
self.config.common.collection_name
))));
}
// checking reachability
let client = self.config.common.build_client().await?;
let client = ClientGuard::new(self.param.sink_name.clone(), client);
client
.database("admin")
.run_command(doc! {"hello":1})
.await
.map_err(|err| {
SinkError::Mongodb(anyhow!(err).context("failed to send hello command to mongodb"))
})?;
if self.config.drop_collection_name_field && self.config.collection_name_field.is_none() {
return Err(SinkError::Config(anyhow!(View on GitHub (pinned to 6469eb736d)
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.
Example fix
-- before CREATE SINK s FROM mv INTO mongodb WITH ( connector='mongodb', url='mongodb://localhost:27017', collection='mycoll' ); -- after CREATE SINK s FROM mv INTO mongodb WITH ( connector='mongodb', url='mongodb://localhost:27017', collection='mydb.mycoll' );
Defensive patterns
Strategy: validation
Validate before calling
// collection must parse as db.collection
const parts = (sinkOptions.collection ?? "").split(".");
if (parts.length !== 2 || parts.some(p => p.length === 0)) {
throw new Error(`collection must be in database.collection form: ${sinkOptions.collection}`);
} Prevention
- 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
When it happens
Trigger: CREATE SINK into mongodb where `collection.name` (e.g., option `collection`) is missing the `db.collection` form, contains invalid characters, or is empty.
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- parsing default namespace failed
- Primary key not defined for upsert mongodb sink (please defi
- collection.name.field must be specified when collection.name
- sink type unsupported: {}
- sink format unsupported: {}
AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11).
Data as JSON: /api/errors/61be6548891fe273.
Report an issue: GitHub.