risingwavelabs/risingwave · error · SinkError::Config

collection.name.field must be specified when collection.name

Error message

collection.name.field must be specified when collection.name.field.drop is enabled

What it means

The option `collection.name.field.drop` (drop the dynamic collection-name column from outgoing documents) only makes sense together with `collection.name.field`, which names that column. `validate` rejects enabling the drop flag without specifying the field. This is a fail-fast config consistency check.

Source

Thrown at src/connector/src/sink/mongodb.rs:332

            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!(
                "collection.name.field must be specified when collection.name.field.drop is enabled"
            )));
        }

        // checking dynamic collection name settings
        if let Some(coll_field) = &self.config.collection_name_field {
            let fields = self.schema.fields();

            let coll_field_index = fields
                .iter()
                .enumerate()
                .find_map(|(index, field)| {
                    if &field.name == coll_field {
                        Some(index)
                    } else {
                        None
                    }
                })

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Add `collection.name.field='<column>'` to the WITH options.
  2. If dynamic collections are not needed, remove the `collection.name.field.drop` option.
  3. Verify exact option names against the current RisingWave connector docs.

Example fix

-- before
CREATE SINK s FROM mv INTO mongodb WITH (
  connector='mongodb', collection='db.c', collection.name.field.drop='true'
);
-- after
CREATE SINK s FROM mv INTO mongodb WITH (
  connector='mongodb', collection='db.c',
  collection.name.field='target_collection', collection.name.field.drop='true'
);
Defensive patterns

Strategy: validation

Validate before calling

if (options['collection.name.field.drop'] != null && options['collection.name.field'] == null) {
  throw new Error("collection.name.field is required when collection.name.field.drop is set");
}

Prevention

When it happens

Trigger: CREATE SINK into mongodb with `collection.name.field.drop='true'` (or similar) in WITH options but no `collection.name.field` option.

Common situations: Users enabling drop-after-write thinking it implies dynamic collection routing; copying config snippets and omitting the field name; renaming options across versions.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/7bc7355fba09506e. Report an issue: GitHub.