influxdata/influxdb · error · Error

unexpected

Error message

unexpected: {0:?}

What it means

The Anyhow variant wraps an anyhow::Error for unexpected/unclassified errors, formatted with Debug ({0:?}) to include the full context chain. It marks failures the library did not map to a specific variant (ObjStorePath, WriteBuffer, Persister, etc.). Because it's Debug-formatted, treat it as an internal/unexpected condition worth reporting.

Solutions

  1. Read the full Debug chain of the wrapped anyhow::Error — it includes backtrace and every context message
  2. Map the root cause to the appropriate subsystem and fix or report as a bug if it indicates an invariant violation
  3. Add proper error variants upstream so this stays classified rather than falling into anyhow
  4. Check versions of influxdb3 crates for known fixes matching the wrapped message

Example fix

// before
Err(anyhow!("chunk not found for id {}", id)) // surfaces as unexpected
// after
return Err(Error::resource_not_found(...)); // a classified variant
Defensive patterns

Strategy: try-catch

Type guard

fn is_unexpected(e: &influxdb3_write::Error) -> Option<&anyhow::Error> {
    match e { influxdb3_write::Error::Anyhow(a) => Some(a), _ => None }
}

Try / catch

match op().await {
    Err(influxdb3_write::Error::Anyhow(a)) => {
        log::error!("unexpected internal error: {:#}", a); // full context chain
        // report as a bug unless the root cause is a known subsystem failure
        Err(a)
    }
    r => r,
}

Prevention

When it happens

Trigger: Any operation in the write-buffer/persister stack returning anyhow::Error not converted to a specific variant: unexpected internal states, third-party errors bubbled via anyhow context, or bugs in glue code.

Common situations: Upgrading components where new inner error types appear as anyhow errors; race conditions or invariant violations surfaced as context-rich anyhow chains; plugin/extension code returning anyhow errors.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19). Data as JSON: /api/errors/bd71f2ce9f26af5f. Report an issue: GitHub.

Appendix: source

Thrown at influxdb3_write/src/lib.rs:60

use serde::{Deserialize, Serialize};
use std::{fmt::Debug, sync::Arc};
use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {
    #[error("object store path error: {0}")]
    ObjStorePath(#[from] object_store::path::Error),

    #[error("write buffer error: {0}")]
    WriteBuffer(#[from] write_buffer::Error),

    #[error("persister error: {0}")]
    Persister(#[from] persister::PersisterError),

    #[error("queries not supported in compactor only mode")]
    CompactorOnly,

    #[error("unexpected: {0:?}")]
    Anyhow(#[from] anyhow::Error),
}

pub type Result<T, E = Error> = std::result::Result<T, E>;

pub trait WriteBuffer: Bufferer + ChunkContainer + DistinctCacheManager + LastCacheManager {}

/// The buffer is for buffering data in memory and in the wal before it is persisted as parquet files in storage.
#[async_trait]
pub trait Bufferer: Debug + Send + Sync + 'static {
    /// Validates the line protocol, writes it into the WAL if configured, writes it into the in memory buffer
    /// and returns the result with any lines that had errors and summary statistics.
    async fn write_lp(
        &self,
        database: DatabaseName,
        lp: &str,
        ingest_time: Time,
        accept_partial: bool,

View on GitHub (pinned to 06200ef96b)