{"record":{"id":"63d6f74ed4d24466","repo":"risingwavelabs/risingwave","slug":"nats-connect-mode-must-be-one-of-user-and-passwor","errorCode":null,"errorMessage":"NATS connect mode must be one of `user_and_password`, `credential`, or `plain`","messagePattern":"NATS connect mode must be one of `user_and_password`, `credential`, or `plain`","errorType":"validation","errorClass":"ConnectorError","httpStatus":null,"severity":"error","filePath":"src/connector/src/connector_common/common.rs","lineNumber":1072,"sourceCode":"                } else {\n                    bail!(\n                        \"NATS connect mode `user_and_password` requires both `user` and `password`\"\n                    );\n                }\n            }\n\n            \"credential\" => {\n                if let (Some(v_nkey), Some(v_jwt)) = (self.nkey.as_ref(), self.jwt.as_ref()) {\n                    connect_options = connect_options\n                        .credentials(&self.create_credential(v_nkey, v_jwt)?)\n                        .expect(\"failed to parse static creds\")\n                } else {\n                    bail!(\"NATS connect mode `credential` requires both `nkey` and `jwt`\");\n                }\n            }\n            \"plain\" => {}\n            _ => {\n                bail!(\n                    \"NATS connect mode must be one of `user_and_password`, `credential`, or `plain`\"\n                );\n            }\n        };\n\n        let servers = self.server_url.split(',').collect::<Vec<&str>>();\n        let client = connect_options\n            .connect(\n                servers\n                    .iter()\n                    .map(|url| url.parse())\n                    .collect::<Result<Vec<async_nats::ServerAddr>, _>>()?,\n            )\n            .await\n            .context(\"failed to build the NATS client\")\n            .map_err(SinkError::Nats)?;\n        Ok(client)\n    }","sourceCodeStart":1054,"sourceCodeEnd":1090,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/connector_common/common.rs#L1054-L1090","documentation":"Thrown by the NATS connect-options builder when `connect_mode` holds a value outside the three supported variants: `user_and_password`, `credential`, or `plain`. The mode string is matched literally and the catch-all arm rejects anything else.","triggerScenarios":"Setting `connect_mode` to a misspelled or unsupported value like 'user_password', 'jwt', 'nkey', or 'anonymous' when creating a NATS source/sink.","commonSituations":"Typos, copying config from a different system with different mode names, or assuming case-insensitivity ('Plain', 'PLAIN').","solutions":["Set `connect_mode` to exactly one of: `user_and_password`, `credential`, or `plain` (lowercase).","Fix spelling/casing of the connect_mode value.","Omit connect_mode entirely if you want the default behavior."],"exampleFix":"// before\nWITH (connect_mode = 'user_password', user = 'u', password = 'p')\n// after\nWITH (connect_mode = 'user_and_password', user = 'u', password = 'p')","handlingStrategy":"validation","validationCode":"const VALID_MODES = ['user_and_password', 'credential', 'plain'];\nfunction validateConnectMode(mode) {\n  if (mode !== undefined && !VALID_MODES.includes(mode)) {\n    throw new Error(`connect_mode must be one of ${VALID_MODES.join(', ')}, got: ${mode}`);\n  }\n}\nvalidateConnectMode(withOptions.connect_mode);","typeGuard":"const isValidMode = (m) => m === undefined || ['user_and_password', 'credential', 'plain'].includes(m);","tryCatchPattern":"try { await createNatsSink(opts); } catch (e) { if (String(e).includes('NATS connect mode must be one of')) throw new Error(`Invalid connect_mode '${opts.connect_mode}': use user_and_password, credential, or plain`); throw e; }","preventionTips":["Copy connect_mode values exactly from documentation (lowercase, underscores).","Use a config schema/enum check in deployment tooling for connect_mode.","Omit connect_mode rather than guessing a value when unsure."],"tags":["nats","config","enum","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"}