risingwavelabs/risingwave · error · SinkError::Mongodb

parsing default namespace failed

Error message

parsing default namespace failed

What it means

When constructing the sink (`new`), the configured `collection_name` is re-parsed into a MongoDB `Namespace` to obtain the default target (database + collection). A parse failure here is wrapped as 'parsing default namespace failed'. This is the runtime-constructor counterpart of the validate-time check (error 743), surfacing when the sink is instantiated (e.g., after recovery) even if validation was bypassed.

Source

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

}

impl MongodbSinkWriter {
    pub async fn new(
        name: String,
        config: MongodbConfig,
        schema: Schema,
        pk_indices: Vec<usize>,
        is_append_only: bool,
    ) -> Result<Self> {
        let client = config.common.build_client().await?;

        let default_namespace =
            config
                .common
                .collection_name
                .parse()
                .map_err(|err: mongodb::error::Error| {
                    SinkError::Mongodb(anyhow!(err).context("parsing default namespace failed"))
                })?;

        let coll_name_field_index =
            config
                .collection_name_field
                .as_ref()
                .and_then(|coll_name_field| {
                    schema
                        .names_str()
                        .iter()
                        .position(|&name| coll_name_field == name)
                });

        let col_indices = if let Some(coll_name_field_index) = coll_name_field_index
            && config.drop_collection_name_field
        {
            (0..schema.fields.len())
                .filter(|idx| *idx != coll_name_field_index)

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Fix the `collection` option to be in `database.collection` form with valid characters.
  2. Drop and recreate the sink with a corrected collection name.
  3. Check the wrapped mongodb::error::Error in the chain for the exact parse failure reason.

Example fix

// before
let config = MongodbConfig::from_btreemap(properties_with(collection = "justcoll"));
// after
let config = MongodbConfig::from_btreemap(properties_with(collection = "mydb.justcoll"));
Defensive patterns

Strategy: try-catch

Validate before calling

// reuse the same check as error 743 before constructing the sink
if (!/^[^\s.]+\.[^\s.]+$/.test(options.collection ?? "")) {
  throw new Error(`invalid namespace: ${options.collection}`);
}

Try / catch

try {
  const sink = await MongodbSink::new(config, ...);
} catch (e) {
  if (String(e).includes("parsing default namespace failed")) {
    // fix collection.name to database.collection form, then recreate the sink
  }
  throw e;
}

Prevention

When it happens

Trigger: Instantiating the mongodb sink with a `collection_name` that is not a valid `db.collection` namespace — e.g., missing separator, empty string, invalid characters.

Common situations: Config drift between validate and create; sinks created before stricter validation; programmatic/SDK-driven sink creation with a malformed name; recovery re-running `new` on stored options.

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


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