{"record":{"id":"d5df09e59a0c47bf","repo":"influxdata/influxdb","slug":"all-datapoints-must-have-at-least-one-field-builder-contains","errorCode":null,"errorMessage":"All `DataPoints` must have at least one field. Builder contains: {:?}","messagePattern":"All `DataPoints` must have at least one field\\. Builder contains: (.+?)","errorType":"validation","errorClass":"DataPointError","httpStatus":null,"severity":"error","filePath":"core/influxdb2_client/src/models/data_point.rs","lineNumber":66,"sourceCode":"\n    /// Sets a field, replacing any existing field of the same name.\n    pub fn field(mut self, name: impl Into<String>, value: impl Into<FieldValue>) -> Self {\n        self.fields.insert(name.into(), value.into());\n        self\n    }\n\n    /// Sets the timestamp, replacing any existing timestamp.\n    ///\n    /// The value is treated as the number of nanoseconds since the\n    /// UNIX epoch.\n    pub fn timestamp(mut self, value: i64) -> Self {\n        self.timestamp = Some(value);\n        self\n    }\n\n    /// Constructs the data point\n    pub fn build(self) -> Result<DataPoint, DataPointError> {\n        ensure!(\n            !self.fields.is_empty(),\n            AtLeastOneFieldRequiredSnafu {\n                data_point_builder: self\n            }\n        );\n\n        let Self {\n            measurement,\n            tags,\n            fields,\n            timestamp,\n        } = self;\n\n        Ok(DataPoint {\n            measurement,\n            tags,\n            fields,\n            timestamp,","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/influxdb2_client/src/models/data_point.rs#L48-L84","documentation":"`DataPointError::AtLeastOneFieldRequired` is returned by `DataPointBuilder::build()` when no fields were added to the builder. An InfluxDB line-protocol data point must carry at least one field (measurement + fields are the minimal valid point); tags alone or a bare timestamp are not a valid point, so the builder refuses to construct it.","triggerScenarios":"Calling `DataPoint::builder(measurement).build()` without any intervening `.field(...)` call, e.g. building points from records where all field values were filtered out as None, or only setting tags/timestamp before `build()`.","commonSituations":"Dynamically constructing points from JSON/CSV rows where field extraction produced an empty map; converting telemetry events where only tags were present; forgetting the builder call chain step that adds fields.","solutions":["Add at least one `.field(\"name\", value)` call before `.build()`.","If fields are computed dynamically, check the field map is non-empty and skip/skip-write points with no fields.","If a record legitimately has no fields, decide on an explicit policy: drop the record or log a warning rather than attempting to write it.","Verify your extraction logic is not discarding all field values (e.g. null filtering too aggressive)."],"exampleFix":"// before\nlet point = DataPoint::builder(\"cpu\")\n    .tag(\"host\", \"server01\")\n    .build()?; // error: no fields\n// after\nlet point = DataPoint::builder(\"cpu\")\n    .tag(\"host\", \"server01\")\n    .field(\"usage\", 0.64)\n    .build()?;","handlingStrategy":"validation","validationCode":"if fields.is_empty() {\n    return Err(\"data point requires at least one field\".into());\n}","typeGuard":null,"tryCatchPattern":"match builder_result {\n    Err(e) if e.to_string().contains(\"at least one field\") => {\n        log::debug!(\"skipping point with no fields\");\n        return Ok(());\n    }\n    other => other,\n}","preventionTips":["Always call at least one `.field(...)` before `.build()`","Filter out points with empty field maps before writing batches","Add a unit test asserting generated points always have >= 1 field"],"tags":["rust","influxdb-client","line-protocol","validation"],"backgroundTag":"empty-required-field","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"}