{"record":{"id":"f5c33fbcedb2977c","repo":"influxdata/influxdb","slug":"bind-parameter-0-was-provided-but-not-found-in-the-influxql","errorCode":null,"errorMessage":"Bind parameter '{0}' was provided but not found in the InfluxQL statement","messagePattern":"Bind parameter '(.+?)' was provided but not found in the InfluxQL statement","errorType":"validation","errorClass":"BindParameterError","httpStatus":null,"severity":"error","filePath":"core/influxdb_influxql_parser/src/parameter.rs","lineNumber":41,"sourceCode":"use nom::branch::alt;\nuse nom::bytes::complete::tag;\nuse nom::character::complete::{alphanumeric1, char};\nuse nom::combinator::{map, recognize};\nuse nom::multi::many1_count;\nuse nom::sequence::preceded;\nuse std::fmt;\nuse std::fmt::{Display, Formatter, Write};\n\n#[derive(Debug, Clone, Error)]\n/// Errors that occur during bind parameter replacement\npub enum BindParameterError {\n    /// Error that occurs when the user provides a parameter value\n    /// whose type is not supported by InfluxQL.\n    #[error(\"Parameter type '{0}' is not supported by InfluxQL\")]\n    TypeNotSupported(String),\n    /// Error that occurs when the user provides a parameter value that\n    /// was not found within the query/statement.\n    #[error(\"Bind parameter '{0}' was provided but not found in the InfluxQL statement\")]\n    NotFound(String),\n    /// Error that occurs when a query contains a bind parameter placeholder\n    /// but the corresponding parameter value was not provided by the user.\n    #[error(\n        \"Bind parameter '{0}' was referenced in the InfluxQL statement but its value is undefined.\"\n    )]\n    NotDefined(String),\n}\n\n/// Parse an unquoted InfluxQL bind parameter.\nfn unquoted_parameter(i: &str) -> ParseResult<&str, &str> {\n    recognize(many1_count(alt((alphanumeric1, tag(\"_\"))))).parse(i)\n}\n\n/// A type that represents an InfluxQL bind parameter.\n#[derive(Clone, Debug, Eq, Hash, PartialEq)]\npub struct BindParameter(pub(crate) String);\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/influxdb_influxql_parser/src/parameter.rs#L23-L59","documentation":"`BindParameterError::NotFound` is raised when the user supplies a bind parameter value that no placeholder in the InfluxQL statement references. The library treats unused supplied parameters as an error so typos/mismatches between parameters and the query are surfaced instead of silently ignored.","triggerScenarios":"Calling the bind-parameter replacement API with a parameters map containing a key that does not appear as a placeholder (e.g. `$foo`/`$bar` mismatch) in the parsed InfluxQL statement.","commonSituations":"Renaming a placeholder in the query but not in the parameter map (or vice versa); reusing a shared parameter set across different queries; case-sensitivity mismatches in parameter names.","solutions":["Remove the unused parameter from the supplied map, or fix its name to match the placeholder in the statement.","Diff the parameter keys against the placeholders extracted from the statement before binding.","Build query text and parameters together from a shared constant to avoid name drift.","Watch for case differences — parameter names must match exactly."],"exampleFix":"// before\nlet params = vec![(\"host_name\", json!(\"server01\"))]; // stmt uses $host\n// after\nlet params = vec![(\"host\", json!(\"server01\"))]; // matches $host in statement","handlingStrategy":"validation","validationCode":"let provided: HashSet<&str> = params.iter().map(|(k, _)| *k).collect();\nlet extra: Vec<_> = provided.difference(&placeholders_in_statement).collect();\nif !extra.is_empty() { return Err(format!(\"unused parameters: {extra:?}\")); }","typeGuard":null,"tryCatchPattern":"match bind_result {\n    Err(BindParameterError::NotFound(name)) => {\n        log::warn!(\"parameter '{name}' not in statement; check for name mismatch\");\n    }\n    other => other,\n}","preventionTips":["Derive parameter names and placeholders from shared constants","Diff supplied parameter keys against statement placeholders before binding","Be consistent with parameter naming conventions across queries"],"tags":["rust","influxql","bind-parameters","naming"],"backgroundTag":"invalid-query-parameter","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"}