{"record":{"id":"fff5ac6ffea46cf0","repo":"risingwavelabs/risingwave","slug":"max-num-messages-expect-usize","errorCode":null,"errorMessage":"max.num.messages expect usize","messagePattern":"max\\.num\\.messages expect usize","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/src/source/kafka/source/reader.rs","lineNumber":186,"sourceCode":"            \"backfill_info: {:?}\",\n            backfill_info\n        );\n\n        consumer.assign(&tpl)?;\n\n        // The two parameters below are only used by developers for performance testing purposes,\n        // so we panic here on purpose if the input is not correctly recognized.\n        let bytes_per_second = match properties.bytes_per_second {\n            None => usize::MAX,\n            Some(number) => number\n                .parse::<usize>()\n                .expect(\"bytes.per.second expect usize\"),\n        };\n        let max_num_messages = match properties.max_num_messages {\n            None => usize::MAX,\n            Some(number) => number\n                .parse::<usize>()\n                .expect(\"max.num.messages expect usize\"),\n        };\n\n        Ok(Self {\n            consumer,\n            offsets,\n            splits,\n            backfill_info,\n            known_eof_offsets,\n            bytes_per_second,\n            sync_call_timeout: properties.common.sync_call_timeout,\n            max_num_messages,\n            parser_config,\n            source_ctx,\n        })\n    }\n\n    fn into_stream(self) -> BoxSourceChunkStream {\n        let parser_config = self.parser_config.clone();","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/source/kafka/source/reader.rs#L168-L204","documentation":"In `KafkaSplitReader::new` (src/connector/src/source/kafka/source/reader.rs:186), the developer-only tuning option `max.num.messages` must parse as a `usize`. Like `bytes.per.second`, it is used only for performance testing, so invalid values deliberately panic with `.expect(\"max.num.messages expect usize\")` rather than producing a normal connector error.","triggerScenarios":"Creating a Kafka source with `max.num.messages` set to a non-integer string (e.g. `'100k'`, `'ten'`) or an integer exceeding usize range, while the option is Some.","commonSituations":"Developers throttling/testing Kafka consumption who pass abbreviated values like `'1000 messages'` or `'1e6'` instead of a plain decimal integer.","solutions":["Set `max.num.messages` to a plain integer, e.g. `max.num.messages = '1000'`.","Remove the `max.num.messages` option if not needed (defaults to usize::MAX).","Use scientific-free decimal notation (no `1e6`, no suffixes)."],"exampleFix":"// before (WITH option)\nmax.num.messages = '1e6'\n// after\nmax.num.messages = '1000000'","handlingStrategy":"validation","validationCode":"// Pre-validate the WITH option before CREATE SOURCE\nlet max_msgs: Option<usize> = props.max_num_messages.as_ref().map(|s| {\n    s.parse().expect(\"max.num.messages must be a plain integer\")\n});","typeGuard":null,"tryCatchPattern":"// This path panics (expect), not returns Result; guard at construction\nlet max_msgs = props.max_num_messages.as_deref()\n    .map(str::parse::<usize>)\n    .transpose()\n    .map_err(|_| anyhow!(\"max.num.messages expect usize\"))?;","preventionTips":["Pass plain decimal integers only (no suffixes like '1k', no scientific notation)","Omit the option to use the unlimited default","Keep a lint/check script for source WITH options used in perf tests"],"tags":["kafka","config","panic","performance-testing"],"backgroundTag":"invalid-config-value","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}