influxdata/influxdb · error · Error::SerdeUrlDecoding

error decoding params from url

Error message

error decoding params from url: {0}

What it means

`Error::SerdeUrlDecoding` wraps `serde_urlencoded::de::Error` and is thrown when URL-encoded request parameters (query string or form body) cannot be deserialized into the expected parameter struct. It is auto-converted via `#[from]`, so any form/query decode failure in the handler surfaces with this message.

Solutions

  1. URL-encode all parameter values (use the client's query/form builder instead of string concatenation).
  2. Check the query string parses: run `serde_urlencoded::from_str` on it locally to reproduce.
  3. Verify parameter names match the current API contract.

Example fix

// before
let url = format!("/query?db={}&q={}", db, q); // unencoded
// after
let url = Url::parse_with_params("http://host/query", &[("db", db), ("q", q)])?;
Defensive patterns

Strategy: validation

Validate before calling

use url::Url;
fn build_query_url(base: &str, db: &str, q: &str) -> Result<String, url::ParseError> {
    Ok(Url::parse_with_params(base, &[("db", db), ("q", q)])?.into())
}

Type guard

fn is_serde_url_error(e: &iox_v1_query_api::Error) -> bool {
    matches!(e, iox_v1_query_api::Error::SerdeUrlDecoding(_))
}

Try / catch

match api.query_urlencoded(&params).await {
    Err(e) if is_serde_url_error(&e) => eprintln!("malformed query string: {e}"),
    other => other,
}

Prevention

When it happens

Trigger: GET /query with a malformed query string (bad percent-encoding, invalid UTF-8 escapes, duplicate/unsupported keys), or POST with a urlencoded body that fails to deserialize.

Common situations: Clients that do not percent-encode special characters (`&`, `=`, `+`, spaces) inside parameter values, hand-concatenated URLs, or parameter names that changed between API versions.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


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

Appendix: source

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

    #[error("invalid mime type ({0})")]
    InvalidMimeType(String),

    /// Missing parameters for query
    #[error("missing query parameters 'db' and 'q'")]
    MissingQueryParams,

    #[error("error decoding multipart file upload: {0}")]
    MultipartFile(String),

    #[error("Invalid UTF8: {message} {error}")]
    Utf8 {
        message: &'static str,
        error: String,
    },

    /// Serde decode error
    #[error("error decoding params from url: {0}")]
    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,

View on GitHub (pinned to 06200ef96b)