{"record":{"id":"f6ac1bd174949b7b","repo":"influxdata/influxdb","slug":"params","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"error_code","errorClass":"Error::Conversion","httpStatus":null,"severity":"error","filePath":"core/iox_query_params/src/params.rs","lineNumber":36,"sourceCode":"use datafusion::common::metadata::ScalarAndMetadata;\nuse datafusion::scalar::ScalarValue;\nuse serde::{Deserialize, Serialize};\nuse thiserror::Error;\nuse tracing::warn;\n\n// remap protobuf types for convenience\nmod proto {\n    pub(super) use generated_types::influxdata::iox::querier::v1::{\n        QueryParam,\n        query_param::{NullValue, Value},\n    };\n}\n\n#[derive(Debug, Error)]\n/// Parameter errors\npub enum Error {\n    /// Data conversion error\n    #[error(\"{}\", msg)]\n    Conversion { msg: String },\n}\n\n/// A helper macro to construct a `StatementParams` collection.\n/// ```\n/// use iox_query_params::{params, StatementParams};\n/// let my_params: StatementParams = params!(\n///     \"key1\" => true,\n///     \"key2\" => \"string value\",\n///     \"key3\" => 1234,\n///     \"key4\" => 3.14\n/// );\n/// assert_eq!(my_params.len(), 4);\n/// ```\n#[macro_export]\nmacro_rules! params {\n    () => (\n        $crate::StatementParams::new()","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/iox_query_params/src/params.rs#L18-L54","documentation":"This is the sole variant of `iox_query_params::Error`, representing a data conversion failure when building or parsing statement parameters. The library throws it when a parameter value cannot be converted into the expected internal representation; the human-readable detail is carried in the `msg` String field, so the message text is fully dynamic (rendered via `#[error(\"{}\", msg)]`).","triggerScenarios":"Constructing a `StatementParams` via the `params!` helper or the `Conversion { msg }` variant directly whenever a supplied parameter value fails type/value conversion (e.g. a value that cannot be coerced to the expected column/parameter type).","commonSituations":"Passing wrong-typed bind values to InfluxDB IOx query parameters, switching parameter APIs between versions and sending strings where numbers are expected, or wrapping lower-level conversion errors from value parsing into this enum.","solutions":["Read the `msg` payload — it contains the exact conversion failure description; fix the offending parameter value or type.","Ensure parameter values match the expected types before calling `params!` (cast/parse explicitly with `serde_json::Value` helpers).","Match on `iox_query_params::Error::Conversion { msg }` at the call site to surface `msg` to the user instead of a generic 500."],"exampleFix":"// before\nlet p = params![\"value\" => user_input]; // may fail conversion\n// after\nlet typed: i64 = user_input.parse().map_err(|e| Error::Conversion { msg: e.to_string() })?;\nlet p = params![\"value\" => typed];","handlingStrategy":"validation","validationCode":"fn ensure_param_ok(v: &serde_json::Value) -> Result<(), iox_query_params::Error> {\n    if !v.is_string() && !v.is_i64() && !v.is_f64() && !v.is_boolean() {\n        return Err(iox_query_params::Error::Conversion { msg: format!(\"unsupported param value: {:?}\", v) });\n    }\n    Ok(())\n}","typeGuard":"fn is_scalar(v: &serde_json::Value) -> bool {\n    matches!(v, serde_json::Value::String(_) | serde_json::Value::Number(_) | serde_json::Value::Bool(_))\n}","tryCatchPattern":"match build_params(user_input) {\n    Ok(p) => run(p),\n    Err(iox_query_params::Error::Conversion { msg }) => eprintln!(\"bad parameter: {msg}\"),\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Coerce user input to explicit types (i64/f64/String) before placing it in `params!`.","Unit-test parameter construction with boundary/edge values.","Wrap `params!` in a helper that maps conversion failures into domain errors with context."],"tags":["rust","query-parameters","data-conversion","thiserror"],"backgroundTag":"type-mismatch","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"}