{"record":{"id":"719933ccd3bda27b","repo":"influxdata/influxdb","slug":"bind-parameter-0-was-referenced-in-the-influxql-statement","errorCode":null,"errorMessage":"Bind parameter '{0}' was referenced in the InfluxQL statement but its value is undefined.","messagePattern":"Bind parameter '(.+?)' was referenced in the InfluxQL statement but its value is undefined\\.","errorType":"validation","errorClass":"BindParameterError","httpStatus":null,"severity":"error","filePath":"core/influxdb_influxql_parser/src/parameter.rs","lineNumber":45,"sourceCode":"use 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\nimpl_tuple_clause!(BindParameter, String);\n\nimpl From<&str> for BindParameter {\n    fn from(s: &str) -> Self {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/influxdb_influxql_parser/src/parameter.rs#L27-L63","documentation":"`BindParameterError::NotDefined` is raised when the InfluxQL statement contains a bind parameter placeholder but the user did not provide a value for it. Substitution cannot complete because the referenced parameter is undefined, so the library fails the query preparation with this error naming the missing parameter.","triggerScenarios":"Executing an InfluxQL statement containing a placeholder (e.g. `$host`) while the supplied parameter set omits that key, via the bind-parameter replacement API in parameter.rs.","commonSituations":"Conditionally building a parameter map where one optional value was skipped but the query still references it; copying a query template with more placeholders than the caller fills; user-supplied queries with placeholders not accounted for by the application.","solutions":["Supply a value for the named placeholder in the parameters map.","If the predicate is optional, rewrite the statement to drop the placeholder when the value is absent.","Validate placeholder coverage: extract all placeholders from the statement and assert every one has a value before executing.","Review query templates for placeholders that are no longer populated by the calling code."],"exampleFix":"// before\n// query: SELECT * FROM cpu WHERE host = $host\nlet params: Vec<(&str, Value)> = vec![]; // $host undefined\n// after\nlet params: Vec<(&str, Value)> = vec![(\"host\", json!(\"server01\"))];","handlingStrategy":"validation","validationCode":"let missing: Vec<_> = placeholders_in_statement\n    .iter()\n    .filter(|p| !params.iter().any(|(k, _)| k == *p))\n    .collect();\nif !missing.is_empty() { return Err(format!(\"missing bind parameters: {missing:?}\")); }","typeGuard":null,"tryCatchPattern":"match bind_result {\n    Err(BindParameterError::NotDefined(name)) => {\n        return Err(anyhow!(\"provide a value for parameter '{name}' or drop its predicate\"));\n    }\n    other => other,\n}","preventionTips":["Build the query and its parameter map together so placeholders always have values","Strip optional predicates from the SQL text when their values are absent","Validate template queries against the parameters each caller supplies"],"tags":["rust","influxql","bind-parameters","missing-value"],"backgroundTag":"missing-required-argument","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"}