influxdata/influxdb · error · PathError

Invalid database ID

Error message

Invalid database ID: {0}

What it means

PathError::InvalidDbId occurs when parsing the database identifier component of a storage path and the component is not a valid database ID (or expected identifier form). The offending text is included in the message. It protects against silently accepting malformed keys as database paths.

Solutions

  1. Check the offending segment in the error message and correct or remove that object
  2. Regenerate/rebuild the affected metadata via normal API calls instead of manual object-store edits
  3. Verify ID parsing code matches the current path scheme (name vs numeric id)
  4. Restore the bucket subtree from a consistent backup if keys were corrupted

Example fix

// before
// object key: databases/my-db/... (name where numeric id expected)
// after
// use the catalog to look up the id and keep keys as databases/<id>/...
Defensive patterns

Strategy: validation

Validate before calling

fn valid_db_id(seg: &str) -> bool {
    !seg.is_empty() && seg.bytes().all(|b| b.is_ascii_digit())
}

Type guard

fn is_numeric_id(s: &str) -> bool {
    !s.is_empty() && s.chars().all(|c| c.is_ascii_digit())
}

Try / catch

match parse_db_path(key) {
    Err(PathError::InvalidDbId(bad)) => {
        log::warn!("bad db id {:?} in {}; skipping", bad, key);
        None // skip instead of aborting the scan
    }
    Ok(p) => Some(p),
}

Prevention

When it happens

Trigger: Parsing a path whose database segment fails ID validation — e.g. non-numeric where a numeric DB id is expected, empty segment, or an arbitrary name where an ID is required.

Common situations: Manually renaming/moving folders inside the object store bucket; partially deleted catalogs leaving inconsistent keys; test objects with placeholder names like "my-db" where an ID is expected.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


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

Appendix: source

Thrown at influxdb3_write/src/paths.rs:18

use crate::YearMonth;
use chrono::prelude::*;
use influxdb3_id::{DbId, TableId, TableIndexId};
use influxdb3_wal::{SnapshotSequenceNumber, WalFileSequenceNumber};
use object_store::path::Path as ObjPath;
use regex::Regex;
use std::ops::Deref;
use std::str::FromStr;
use std::sync::{Arc, LazyLock};
use thiserror::Error;

/// Errors that can occur when parsing paths
#[derive(Debug, Error)]
pub enum PathError {
    #[error("Invalid path format: expected {expected}, got: {actual}")]
    InvalidFormat { expected: String, actual: String },

    #[error("Invalid database ID: {0}")]
    InvalidDbId(String),

    #[error("Invalid table ID: {0}")]
    InvalidTableId(String),

    #[error("Invalid sequence number in {context}: {filename}")]
    InvalidSequenceNumber { context: String, filename: String },
}

/// File extension for parquet files
pub const PARQUET_FILE_EXTENSION: &str = "parquet";

/// File extension for snapshot info files
pub const SNAPSHOT_INFO_FILE_EXTENSION: &str = "info.json";

/// File extension for checkpoint files
pub const CHECKPOINT_FILE_EXTENSION: &str = "checkpoint.json";

View on GitHub (pinned to 06200ef96b)