influxdata/influxdb · error · V2WriteParseError::DecodeFail
failed to deserialize org/bucket/precision in request
Error message
failed to deserialize org/bucket/precision in request: {0} What it means
V2WriteParseError::DecodeFail wraps serde deserialization failures when parsing the org/bucket/precision parameters of a v2 write request. The parameters exist but fail to deserialize; the underlying serde::de::value::Error is embedded in the message.
Solutions
- Inspect the wrapped serde error in the message to find the offending parameter.
- Use accepted precision values only: ns, u (or us), ms, s.
- URL-encode org and bucket values, especially those containing '/', '&' or '='.
- Match on V2WriteParseError::DecodeFail(_) and return 400 with the decode details.
Example fix
// before POST /api/v2/write?org=myorg&bucket=mybucket&precision=nanoseconds // after POST /api/v2/write?org=myorg&bucket=mybucket&precision=ns
Defensive patterns
Strategy: try-catch
Validate before calling
const PRECISIONS: [&str; 4] = ["ns", "u", "ms", "s"];
if let Some(p) = precision {
assert!(PRECISIONS.contains(&p), "invalid precision: {p}");
}
assert!(!org.is_empty() && !bucket.is_empty()); Try / catch
match err {
V2WriteParseError::DecodeFail(e) => /* 400 with e.to_string() */,
other => /* propagate */,
} Prevention
- Validate precision against the allowed enum before sending.
- URL-encode org/bucket values containing special characters.
- Build query strings with the url crate's query_pairs_mut instead of string concatenation.
When it happens
Trigger: Sending /api/v2/write?org=...&bucket=... with an unsupported precision value or a malformed query string that fails serde_urlencoded decoding.
Common situations: Precision typos (precision=nanoseconds); non-UTF8 or badly percent-encoded parameter values; automation building query strings without encoding.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- failed to deserialize db/rp/precision in request
- no org/bucket destination provided
- no db destination provided
- error reading field from body
- invalid request
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/5aca1c51cfa64f33.
Report an issue: GitHub.
Appendix: source
Thrown at core/iox_http/src/write/v2.rs:21
//!
//! [V2 Write API]:
//! https://docs.influxdata.com/influxdb/v2.6/api/#operation/PostWrite
use iox_http_util::Request;
use serde::Deserialize;
use super::Precision;
/// v2 DmlErrors returned when decoding the organisation / bucket information
/// from a HTTP request and deriving the namespace name from it.
#[derive(Debug, thiserror::Error)]
pub enum V2WriteParseError {
/// The request contains no org/bucket destination information.
#[error("no org/bucket destination provided")]
NoQueryParams,
/// The request contains invalid parameters.
#[error("failed to deserialize org/bucket/precision in request: {0}")]
DecodeFail(#[from] serde::de::value::Error),
}
/// Query parameters for v2 write requests.
#[derive(Debug, Deserialize)]
pub struct WriteParamsV2 {
#[serde(default)]
pub org: String,
#[serde(default)]
pub bucket: String,
#[serde(default)]
pub precision: Precision,
}
impl TryFrom<&Request> for WriteParamsV2 {
type Error = V2WriteParseError;
View on GitHub (pinned to 06200ef96b)