{"record":{"id":"ae4e5492ce21af4e","repo":"influxdata/influxdb","slug":"error-reading-field-from-body-name-error","errorCode":null,"errorMessage":"error reading field from body: {name} -- {error}","messagePattern":"error reading field from body: (.+?) -- (.+?)","errorType":"http","errorClass":"Error::FieldRead","httpStatus":null,"severity":"error","filePath":"core/iox_v1_query_api/src/error.rs","lineNumber":77,"sourceCode":"    InfluxqlNoDatabase,\n\n    #[error(\n        \"provided a database in both the parameters ({param_db}) and \\\n        query string ({query_db}) that do not match, if providing a query \\\n        that specifies the database, you can omit the 'database' parameter \\\n        from your request\"\n    )]\n    InfluxqlDatabaseMismatch { param_db: String, query_db: String },\n\n    #[error(\n        \"provided a retention policy in both the parameters ({param_rp}) and \\\n        query string ({query_rp}) that do not match, if providing a query \\\n        that specifies the retention_policy, you can omit the 'rp' parameter \\\n        from your request\"\n    )]\n    InfluxqlRetentionPolicyMismatch { param_rp: String, query_rp: String },\n\n    #[error(\"error reading field from body: {name} -- {error}\")]\n    FieldRead { name: &'static str, error: String },\n\n    #[error(\"Cannot retrieve database: {0}\")]\n    Database(DataFusionError),\n\n    #[error(\"Database {0} not found\")]\n    DatabaseNotFound(String),\n\n    #[error(\"v1 query API error: {0}\")]\n    V1Query(#[from] QueryError),\n}\n\n#[derive(Debug, Clone)]\npub enum HttpError {\n    NotFound(String),\n    Unauthorized(String),\n    Invalid(String),\n    InternalError(String),","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/iox_v1_query_api/src/error.rs#L59-L95","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":"// before\ncurl -d '{\"q\": \"SELECT 1\"}' /query  # wrong encoding for form endpoint\n// after\ncurl --data-urlencode 'q=SELECT 1' -H 'Content-Type: application/x-www-form-urlencoded' /query","handlingStrategy":"validation","validationCode":"function buildQueryBody(fields) {\n  return Object.fromEntries(\n    Object.entries(fields).filter(([, v]) => v !== undefined).map(([k, v]) => [k, String(v)])\n  );\n}\n// send with explicit Content-Type matching the endpoint\nconst body = new URLSearchParams(buildQueryBody({ q, db, rp }));","typeGuard":null,"tryCatchPattern":"try {\n  await postQuery(body);\n} catch (e) {\n  const m = /error reading field from body: (\\w+)/.exec(e.message);\n  if (m) console.error(`invalid request field: ${m[1]}`);\n  else throw e;\n}","preventionTips":["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."],"tags":["request-body","validation","http","deserialization"],"backgroundTag":"json-parse-error","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"}