influxdata/influxdb · error · ValidateDbNameError

db name cannot be empty

Error message

db name cannot be empty

What it means

Variant `Empty` of `ValidateDbNameError` in influxdb3_server/src/http.rs. The database name supplied to the request was an empty string, which cannot identify any database, so validation fails immediately.

Solutions

  1. Provide a non-empty database name in the request (e.g. `?db=mydb`)
  2. Check the client configuration/env so the database value is actually populated
  3. Add a client-side `if (!db) throw` guard before constructing the request

Example fix

// before
curl 'host/api/v3/write?db=' --data 'm v=1'
// after
curl 'host/api/v3/write?db=mydb' --data 'm v=1'
Defensive patterns

Strategy: validation

Validate before calling

function requireDb(db) {
  if (typeof db !== 'string' || db.length === 0) throw new Error('database name is required and cannot be empty');
}

Type guard

const hasDb = (cfg) => typeof cfg?.database === 'string' && cfg.database.length > 0;

Try / catch

try {
  return await api.write(db, data);
} catch (e) {
  if (String(e.message).includes('db name cannot be empty')) {
    throw new ConfigError('database name missing; check client config / INFLUX_DB env');
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling write/query endpoints with `?db=` (empty value), an unbound template variable, or a config value that resolves to an empty string.

Common situations: Environment variables like INFLUX_DB unset causing empty interpolation; client SDK configured with an empty database field; query builders that omit the db parameter value.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at influxdb3_server/src/http.rs:2434

// retention policy name; we support those combined with a forward slash so
// 255*2+1.
const MAXIMUM_DATABASE_NAME_LENGTH: usize = 511;

#[derive(Clone, Copy, Debug, thiserror::Error)]
pub enum ValidateDbNameError {
    #[error(
        "invalid character in database or rp name: must be ASCII, \
        containing only letters, numbers, underscores, or hyphens"
    )]
    InvalidChar,
    #[error("db name did not start with a number or letter")]
    InvalidStartChar,
    #[error(
        "db name with invalid retention policy, if providing a \
        retention policy name, must be of form '<db_name>/<rp_name>'"
    )]
    InvalidRetentionPolicy,
    #[error("db name cannot be empty")]
    Empty,
    #[error("db name too long: max {}", MAXIMUM_DATABASE_NAME_LENGTH)]
    NameTooLong,
}

async fn record_batch_stream_to_body(
    mut stream: Pin<Box<dyn RecordBatchStream + Send>>,
    format: QueryFormat,
) -> Result<ResponseBody, Error> {
    match format {
        QueryFormat::Pretty => {
            let batches = stream.try_collect::<Vec<RecordBatch>>().await?;
            Ok(bytes_to_response_body(Bytes::from(format!(
                "{}",
                pretty::pretty_format_batches(&batches)?
            ))))
        }
        QueryFormat::Parquet => {

View on GitHub (pinned to 06200ef96b)