{"record":{"id":"623435565c3d3d9d","repo":"quickwit-oss/quickwit","slug":"failed-to-parse-kafka-client-parameters-client-p","errorCode":null,"errorMessage":"failed to parse Kafka client parameters. `client_params` must be a JSON object","messagePattern":"failed to parse Kafka client parameters\\. `client_params` must be a JSON object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-indexing/src/source/kafka_source.rs","lineNumber":712,"sourceCode":"        Some(\"info\") | None => RDKafkaLogLevel::Info,\n        Some(\"warn\") | Some(\"warning\") => RDKafkaLogLevel::Warning,\n        Some(\"error\") => RDKafkaLogLevel::Error,\n        Some(\"critical\") => RDKafkaLogLevel::Critical,\n        Some(\"alert\") => RDKafkaLogLevel::Alert,\n        Some(\"emerg\") => RDKafkaLogLevel::Emerg,\n        Some(level) => bail!(\n            \"failed to parse Kafka client log level. value `{}` is not supported\",\n            level\n        ),\n    };\n    Ok(log_level)\n}\n\nfn parse_client_params(client_params: JsonValue) -> anyhow::Result<ClientConfig> {\n    let params = if let JsonValue::Object(params) = client_params {\n        params\n    } else {\n        bail!(\"failed to parse Kafka client parameters. `client_params` must be a JSON object\");\n    };\n    let mut client_config = ClientConfig::new();\n    for (key, value_json) in params {\n        let value = match value_json {\n            JsonValue::Bool(value_bool) => value_bool.to_string(),\n            JsonValue::Number(value_number) => value_number.to_string(),\n            JsonValue::String(value_string) => value_string,\n            JsonValue::Null => continue,\n            JsonValue::Array(_) | JsonValue::Object(_) => bail!(\n                \"failed to parse Kafka client parameters. `client_params.{}` must be a boolean, \\\n                 number, or string\",\n                key\n            ),\n        };\n        client_config.set(key, value);\n    }\n    Ok(client_config)\n}","sourceCodeStart":694,"sourceCodeEnd":730,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-indexing/src/source/kafka_source.rs#L694-L730","documentation":"The Kafka source accepts a `client_params` JSON value that must be a JSON object of librdkafka settings. `parse_client_params` bails when the provided value is any other JSON type (string, array, number, etc.).","triggerScenarios":"`create_consumer` or `check_connectivity` receives a source whose `client_params` is a valid JSON but not an object (e.g., a quoted JSON string or an array).","commonSituations":"Double-encoding: embedding a JSON object as a string (`\"client_params\": \"{\\\"group.id\\\":\\\"x\\\"}\"`); pasting a YAML-style list; config template rendered incorrectly.","solutions":["Make `client_params` a JSON object with string keys: `{\"group.id\": \"...\", \"security.protocol\": \"SSL\"}`.","If passing through templating/tooling, unescape the JSON so it is an object, not a string.","Validate the source config JSON before submitting (e.g., `jq .client_params source.json`)."],"exampleFix":"// before\n\"client_params\": \"{\\\"group.id\\\":\\\"qw-group\\\"}\"\n// after\n\"client_params\": { \"group.id\": \"qw-group\" }","handlingStrategy":"type-guard","validationCode":"// JS\nif (typeof params.client_params !== 'object' || Array.isArray(params.client_params)) throw new Error('client_params must be a JSON object');","typeGuard":"function isJsonObject(v) { return v !== null && typeof v === 'object' && !Array.isArray(v); }","tryCatchPattern":"// Rust caller\nlet params: serde_json::Value = serde_json::from_str(raw)?;\nif !params.is_object() { bail!(\"client_params must be a JSON object\"); }","preventionTips":["Pass client_params as a JSON object, never as a JSON-encoded string.","Validate configs with jq/schema checks before applying.","Document example client_params in team runbooks."],"tags":["kafka","json","config-type-mismatch","configuration"],"backgroundTag":"config-type-mismatch","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}