vectordotdev/vector · error · BuildError::InvalidDrainTimeout

The drain_timeout_ms

Error message

The drain_timeout_ms ({}) must be less than session_timeout_ms ({})

What it means

The Kafka source validates that drain_timeout_ms, the grace period given to in-flight messages during shutdown, is not longer than session_timeout_ms, the Kafka consumer session timeout. This error is raised at source build time when drain_timeout_ms exceeds the session timeout, because a drain period longer than the session would let the consumer be kicked from the group mid-drain.

Solutions

  1. Lower drain_timeout_ms so it is <= session_timeout_ms (and per the message, less than it).
  2. Or raise session_timeout_ms to exceed the desired drain timeout.
  3. Remove drain_timeout_ms to use the default behavior.

Example fix

// before (vector.yaml)
sources:
  kafka_in:
    type: kafka
    session_timeout_ms: 10000
    drain_timeout_ms: 30000
// after
sources:
  kafka_in:
    type: kafka
    session_timeout_ms: 10000
    drain_timeout_ms: 5000
Defensive patterns

Strategy: validation

Validate before calling

// pre-check config values before loading
fn drain_timeout_ok(drain_timeout_ms: u64, session_timeout_ms: u64) -> bool {
    drain_timeout_ms <= session_timeout_ms
}

Try / catch

match Vector::build() {
    Err(e) if e.to_string().contains("drain_timeout_ms") => {
        eprintln!("adjust drain_timeout_ms <= session_timeout_ms");
    }
    Err(e) => return Err(e),
    Ok(v) => v,
}

Prevention

When it happens

Trigger: Configuring a Kafka source with drain_timeout_ms set to a value greater than session_timeout_ms (strictly less-than is required by the message text; the code checks d <= session_timeout_ms and errors otherwise).

Common situations: Operators tuning shutdown behavior set a long drain_timeout_ms while leaving the default session_timeout_ms; copying a source config between clusters with different session timeouts.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/9a45e9a3369df53f. Report an issue: GitHub.

Appendix: source

Thrown at src/sources/kafka.rs:342

#[async_trait::async_trait]
#[typetag::serde(name = "kafka")]
impl SourceConfig for KafkaSourceConfig {
    async fn build(&self, cx: SourceContext) -> crate::Result<super::Source> {
        let log_namespace = cx.log_namespace(self.log_namespace);

        let decoder =
            DecodingConfig::new(self.framing.clone(), self.decoding.clone(), log_namespace)
                .build()?;
        let decompressor = self
            .decompression
            .as_ref()
            .map(DecompressionConfig::build)
            .transpose()?;
        let acknowledgements = cx.do_acknowledgements(self.acknowledgements);

        if let Some(d) = self.drain_timeout_ms {
            snafu::ensure!(
                Duration::from_millis(d) <= self.session_timeout_ms,
                InvalidDrainTimeoutSnafu {
                    value: d,
                    session_timeout_ms: self.session_timeout_ms
                }
            );
        }

        let (consumer, callback_rx) = create_consumer(self, acknowledgements)?;

        Ok(Box::pin(kafka_source(
            self.clone(),
            consumer,
            callback_rx,
            decoder,
            decompressor,
            cx.out,
            cx.shutdown,

View on GitHub (pinned to bdb87aeaa4)