influxdata/influxdb · error · Error::FieldRead
error reading field from body
Error message
error reading field from body: {name} -- {error} What it means
Thrown when the server fails to read a field out of the request body while decoding the v1 query payload. `FieldRead { name, error }` names the offending field and carries the underlying read/deserialization error as a string. It indicates a malformed or unreadable request body rather than a query problem.
Solutions
- Check the `name` and `error` fields in the message to identify the failing body field.
- Send the body with the Content-Type the endpoint expects (application/x-www-form-urlencoded or application/json).
- Validate the request payload against the API's expected schema before sending.
- Log the raw request body at the client to confirm what was actually transmitted.
Example fix
// before
curl -d '{"q": "SELECT 1"}' /query # wrong encoding for form endpoint
// after
curl --data-urlencode 'q=SELECT 1' -H 'Content-Type: application/x-www-form-urlencoded' /query Defensive patterns
Strategy: validation
Validate before calling
function buildQueryBody(fields) {
return Object.fromEntries(
Object.entries(fields).filter(([, v]) => v !== undefined).map(([k, v]) => [k, String(v)])
);
}
// send with explicit Content-Type matching the endpoint
const body = new URLSearchParams(buildQueryBody({ q, db, rp })); Try / catch
try {
await postQuery(body);
} catch (e) {
const m = /error reading field from body: (\w+)/.exec(e.message);
if (m) console.error(`invalid request field: ${m[1]}`);
else throw e;
} Prevention
- Always set the Content-Type the endpoint expects.
- Coerce all body fields to strings before form-encoding.
- Log/inspect outgoing request bodies in a debug mode.
When it happens
Trigger: POST to the v1 /query endpoint with a body whose fields cannot be read, e.g. malformed JSON/form encoding, wrong Content-Type, or a field value that cannot be deserialized into the expected type.
Common situations: Sending JSON to an endpoint expecting urlencoded form data (or vice versa); truncated request bodies from proxies; clients serializing fields with unexpected types (number where string expected).
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- failed to deserialize db/rp/precision in request
- failed to deserialize org/bucket/precision in request
- invalid mime type ( )
- missing bucket value
- All `DataPoints` must have at least one field. Builder…
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/ae4e5492ce21af4e.
Report an issue: GitHub.
Appendix: source
Thrown at core/iox_v1_query_api/src/error.rs:77
InfluxqlNoDatabase,
#[error(
"provided a database in both the parameters ({param_db}) and \
query string ({query_db}) that do not match, if providing a query \
that specifies the database, you can omit the 'database' parameter \
from your request"
)]
InfluxqlDatabaseMismatch { param_db: String, query_db: String },
#[error(
"provided a retention policy in both the parameters ({param_rp}) and \
query string ({query_rp}) that do not match, if providing a query \
that specifies the retention_policy, you can omit the 'rp' parameter \
from your request"
)]
InfluxqlRetentionPolicyMismatch { param_rp: String, query_rp: String },
#[error("error reading field from body: {name} -- {error}")]
FieldRead { name: &'static str, error: String },
#[error("Cannot retrieve database: {0}")]
Database(DataFusionError),
#[error("Database {0} not found")]
DatabaseNotFound(String),
#[error("v1 query API error: {0}")]
V1Query(#[from] QueryError),
}
#[derive(Debug, Clone)]
pub enum HttpError {
NotFound(String),
Unauthorized(String),
Invalid(String),
InternalError(String),View on GitHub (pinned to 06200ef96b)