influxdata/influxdb · error · Error

request URL error

Error message

request URL error: {0}

What it means

Error::RequestUrl wraps a url::ParseError produced when the client builds the URL for a specific API request from the base URL plus a path/query. Unlike BaseUrl, the base was fine but a request-path fragment, query parameter, or encoding produced an invalid URL.

Solutions

  1. Percent-encode path/query components (e.g. urlencoding::encode or the url crate's API) before calling the client method.
  2. Sanitize resource names (database/table names) to URL-safe characters.
  3. Verify the base URL is valid; an invalid base can surface here depending on which parse step fails first.

Example fix

// before
client.api_v3_query_database(&format!("{}", raw_user_input)).await?;
// after
let db = urlencoding::encode(&raw_user_input);
client.api_v3_query_database(&db).await?;
Defensive patterns

Strategy: validation

Validate before calling

fn encode_path_segment(s: &str) -> String { urlencoding::encode(s).into_owned() }
// use before building request paths: let db = encode_path_segment(&db_name);

Type guard

fn url_safe(s: &str) -> bool { url::Url::parse(&format!("http://x/{s}")).is_ok() }

Try / catch

match client.api_v3_query_database(&db).await {
    Err(Error::RequestUrl(pe)) => Err(anyhow!("bad request URL for db '{db}': {pe}")),
    other => other,
}

Prevention

When it happens

Trigger: Calling client APIs with query parameters or path segments that fail URL parsing when appended (e.g. invalid characters in a database name, unencodable query values); the conversion comes via `#[from] url::ParseError`.

Common situations: Passing raw, unencoded user input into request paths; empty strings or special characters (spaces, control chars) in resource names used to build request URLs.

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/494d168dbb83d346. Report an issue: GitHub.

Appendix: source

Thrown at influxdb3_client/src/lib.rs:28

    tls::Version,
};
use secrecy::{ExposeSecret, Secret};
use serde::{Serialize, de::DeserializeOwned};
use std::error::Error as _;
use std::io::Write as _;
use std::{fmt::Display, num::NonZeroUsize, path::PathBuf, string::FromUtf8Error, time::Duration};
use url::Url;

use influxdb3_types::http::*;
pub use influxdb3_types::write::Precision;

/// Primary error type for the [`Client`]
#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("base URL error: {}", reqwest_description(.0))]
    BaseUrl(#[source] reqwest::Error),

    #[error("request URL error: {0}")]
    RequestUrl(#[from] url::ParseError),

    #[error("failed to read the API response bytes: {}", reqwest_description(.0))]
    Bytes(#[source] reqwest::Error),

    #[error("failed to serialize the request body: {0}")]
    RequestSerialization(#[source] serde_json::Error),

    #[error(
        "provided parameter ('{name}') could not be converted \
        to a statment parameter"
    )]
    ConvertQueryParam {
        name: String,
        #[source]
        source: iox_query_params::Error,
    },

View on GitHub (pinned to 06200ef96b)