{"record":{"id":"151fe93b1f84560f","repo":"risingwavelabs/risingwave","slug":"must-be-or-151fe9","errorCode":null,"errorMessage":"`{}` must be {}, or {}","messagePattern":"`(.+?)` must be (.+?), or (.+?)","errorType":"validation","errorClass":"SinkError::Config","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/mongodb.rs","lineNumber":171,"sourceCode":"    #[serde(flatten)]\n    pub unknown_fields: std::collections::HashMap<String, String>,\n}\n\ncrate::impl_sink_unknown_fields!(MongodbConfig);\n\nimpl EnforceSecret for MongodbConfig {\n    fn enforce_one(prop: &str) -> crate::error::ConnectorResult<()> {\n        MongodbCommon::enforce_one(prop)\n    }\n}\n\nimpl MongodbConfig {\n    pub fn from_btreemap(properties: BTreeMap<String, String>) -> crate::sink::Result<Self> {\n        let config =\n            serde_json::from_value::<MongodbConfig>(serde_json::to_value(properties).unwrap())\n                .map_err(|e| SinkError::Config(anyhow!(e)))?;\n        if config.r#type != SINK_TYPE_APPEND_ONLY && config.r#type != SINK_TYPE_UPSERT {\n            return Err(SinkError::Config(anyhow!(\n                \"`{}` must be {}, or {}\",\n                SINK_TYPE_OPTION,\n                SINK_TYPE_APPEND_ONLY,\n                SINK_TYPE_UPSERT\n            )));\n        }\n        Ok(config)\n    }\n}\n\n/// An async-drop style `Guard` for `mongodb::Client`. Use this guard to hold a client,\n/// the `client::shutdown` is called in an async manner when the guard is dropped.\n/// Please be aware this is a \"best effort\" style shutdown, which may not be successful if the\n/// tokio runtime is in the process of terminating. However, the server-side resources will be\n/// cleaned up eventually due to the session expiration.\n/// see [this issue](https://github.com/mongodb/mongo-rust-driver/issues/719) for more information\nstruct ClientGuard {\n    _tx: tokio::sync::oneshot::Sender<()>,","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/mongodb.rs#L153-L189","documentation":"Config validation in MongodbConfig::from_btreemap: an enumerated with-clause option (such as the sink `type`) was given a value outside the small allowed set; the message lists the accepted alternatives. Fires when serde-deserialized properties contain a value serde accepted but the explicit check rejects.","triggerScenarios":"config.r#type is neither SINK_TYPE_APPEND_ONLY ('append_only') nor SINK_TYPE_UPSERT ('upsert') — i.e. the user supplied a different 'type' string (or an unexpected default) in the sink WITH options.","commonSituations":"Typo like 'append-only' or 'upsert-only', copying options from another connector with different type names, or forgetting 'type' when the serde default yields an invalid value.","solutions":["Set type = 'append_only' for insert-only sinks or type = 'upsert' for upsert sinks, exactly as spelled.","Check the RisingWave MongoDB sink docs for the accepted type values in your version.","Avoid hyphenated variants like 'append-only'; the constants use underscores.","If the type came from a generated/templated DDL, review the template's WITH block."],"exampleFix":"// before\nWITH (connector = 'mongodb', url = 'mongodb://...', type = 'append-only')\n// after\nWITH (connector = 'mongodb', url = 'mongodb://...', type = 'append_only')","handlingStrategy":"validation","validationCode":"// validate the type value before creating the sink\nconst VALID: [&str; 2] = [\"append_only\", \"upsert\"];\nassert!(VALID.contains(&sink_type.as_str()), \"type must be append_only or upsert, got: {sink_type}\");\n","typeGuard":null,"tryCatchPattern":"// surface the accepted values in the failure path\nmatch sink_type.as_str() {\n    \"append_only\" | \"upsert\" => proceed(),\n    other => return Err(format!(\"invalid type '{other}'; use append_only or upsert\")),\n}","preventionTips":["Use the exact spellings 'append_only' and 'upsert' (underscores, not hyphens).","Copy WITH options from the official docs for the MongoDB connector.","Never reuse the 'type' option names from other connectors.","Lint generated DDL templates against valid enum values."],"tags":["rust","mongodb","config","validation"],"backgroundTag":"invalid-enum-value","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"}