influxdata/influxdb · error · Error::InfluxqlDatabaseMismatch

provided a database in both the parameters

Error message

provided a database in both the parameters ({param_db}) and query string ({query_db}) that do not match, if providing a query that specifies the database, you can omit the 'database' parameter from your request

What it means

Thrown when a database is provided both in the request parameter (`db`) and inside the InfluxQL query string, and the two values differ. The API refuses to guess which one is intended rather than silently picking one. The error message echoes both conflicting values via `param_db` and `query_db`.

Solutions

  1. Make the `db` parameter and the query database identical.
  2. Remove the `db` parameter and rely solely on the query-qualified database.
  3. Or qualify the query with the same database that the parameter provides.

Example fix

// before
GET /query?db=dbA&q=SELECT+*+FROM+"dbB"."autogen".cpu
// after
GET /query?db=dbA&q=SELECT+*+FROM+"dbA"."autogen".cpu
Defensive patterns

Strategy: validation

Validate before calling

function assertDbConsistent(dbParam, q) {
  const m = /FROM\s+"([\w-]+)"\s*\./.exec(q);
  if (dbParam && m && m[1] !== dbParam) {
    throw new Error(`db mismatch: param=${dbParam} query=${m[1]}`);
  }
}

Prevention

When it happens

Trigger: GET/POST to the v1 /query endpoint with `db=dbA` and a query referencing `dbB`, e.g. `?db=dbA&q=SELECT * FROM "dbB"."autogen".cpu`.

Common situations: Templates that hardcode a `db` parameter while queries carry their own database; copy-pasted queries from another environment; dashboard variables resolving to a different database than the connection setting.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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

Appendix: source

Thrown at core/iox_v1_query_api/src/error.rs:61

    SerdeUrlDecoding(#[from] serde_urlencoded::de::Error),

    // SerdeJsonError
    #[error("error decoding query body: {0}")]
    SerdeJson(#[from] serde_json::Error),

    #[error("datafusion error: {0}")]
    Datafusion(#[from] DataFusionError),

    #[error("error in InfluxQL statement: {0}")]
    InfluxqlRewrite(#[from] rewrite::Error),

    #[error("must provide only one InfluxQl statement per query")]
    InfluxqlSingleStatement,

    #[error("must specify a 'db' parameter, or provide the database in the InfluxQL query")]
    InfluxqlNoDatabase,

    #[error(
        "provided a database in both the parameters ({param_db}) and \
        query string ({query_db}) that do not match, if providing a query \
        that specifies the database, you can omit the 'database' parameter \
        from your request"
    )]
    InfluxqlDatabaseMismatch { param_db: String, query_db: String },

    #[error(
        "provided a retention policy in both the parameters ({param_rp}) and \
        query string ({query_rp}) that do not match, if providing a query \
        that specifies the retention_policy, you can omit the 'rp' parameter \
        from your request"
    )]
    InfluxqlRetentionPolicyMismatch { param_rp: String, query_rp: String },

    #[error("error reading field from body: {name} -- {error}")]
    FieldRead { name: &'static str, error: String },

View on GitHub (pinned to 06200ef96b)