{"record":{"id":"23563f9588196f7e","repo":"influxdata/influxdb","slug":"provided-a-database-in-both-the-parameters-param-db-and","errorCode":null,"errorMessage":"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","messagePattern":"provided a database in both the parameters \\((.+?)\\) and query string \\((.+?)\\) that do not match, if providing a query that specifies the database, you can omit the 'database' parameter from your request","errorType":"validation","errorClass":"Error::InfluxqlDatabaseMismatch","httpStatus":null,"severity":"error","filePath":"core/iox_v1_query_api/src/error.rs","lineNumber":61,"sourceCode":"    SerdeUrlDecoding(#[from] serde_urlencoded::de::Error),\n\n    // SerdeJsonError\n    #[error(\"error decoding query body: {0}\")]\n    SerdeJson(#[from] serde_json::Error),\n\n    #[error(\"datafusion error: {0}\")]\n    Datafusion(#[from] DataFusionError),\n\n    #[error(\"error in InfluxQL statement: {0}\")]\n    InfluxqlRewrite(#[from] rewrite::Error),\n\n    #[error(\"must provide only one InfluxQl statement per query\")]\n    InfluxqlSingleStatement,\n\n    #[error(\"must specify a 'db' parameter, or provide the database in the InfluxQL query\")]\n    InfluxqlNoDatabase,\n\n    #[error(\n        \"provided a database in both the parameters ({param_db}) and \\\n        query string ({query_db}) that do not match, if providing a query \\\n        that specifies the database, you can omit the 'database' parameter \\\n        from your request\"\n    )]\n    InfluxqlDatabaseMismatch { param_db: String, query_db: String },\n\n    #[error(\n        \"provided a retention policy in both the parameters ({param_rp}) and \\\n        query string ({query_rp}) that do not match, if providing a query \\\n        that specifies the retention_policy, you can omit the 'rp' parameter \\\n        from your request\"\n    )]\n    InfluxqlRetentionPolicyMismatch { param_rp: String, query_rp: String },\n\n    #[error(\"error reading field from body: {name} -- {error}\")]\n    FieldRead { name: &'static str, error: String },\n","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/iox_v1_query_api/src/error.rs#L43-L79","documentation":"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`.","triggerScenarios":"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`.","commonSituations":"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.","solutions":["Make the `db` parameter and the query database identical.","Remove the `db` parameter and rely solely on the query-qualified database.","Or qualify the query with the same database that the parameter provides."],"exampleFix":"// before\nGET /query?db=dbA&q=SELECT+*+FROM+\"dbB\".\"autogen\".cpu\n// after\nGET /query?db=dbA&q=SELECT+*+FROM+\"dbA\".\"autogen\".cpu","handlingStrategy":"validation","validationCode":"function assertDbConsistent(dbParam, q) {\n  const m = /FROM\\s+\"([\\w-]+)\"\\s*\\./.exec(q);\n  if (dbParam && m && m[1] !== dbParam) {\n    throw new Error(`db mismatch: param=${dbParam} query=${m[1]}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one source of truth for the database: the parameter OR the query, never both.","Strip the database qualifier from queries when a `db` parameter is provided.","Review templated queries for hardcoded database names."],"tags":["influxql","query","conflict","database"],"backgroundTag":"conflicting-config-options","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}