{"record":{"id":"79f69ae8c74fb579","repo":"influxdata/influxdb","slug":"key-type-key-key-cannot-contain-equals-signs","errorCode":null,"errorMessage":"{key_type} key '{key}' cannot contain equals signs","messagePattern":"(.+?) key '(.+?)' cannot contain equals signs","errorType":"exception","errorClass":"InvalidKeyError","httpStatus":null,"severity":"error","filePath":"influxdb3_py_api/src/line_builder/line_builder.py","lineNumber":47,"sourceCode":"class LineBuilder:\n    def __init__(self, measurement: str):\n        if \" \" in measurement:\n            raise InvalidMeasurementError(\"Measurement name cannot contain spaces\")\n        self.measurement = measurement\n        self.tags: OrderedDict[str, str] = OrderedDict()\n        self.fields: OrderedDict[str, str] = OrderedDict()\n        self._timestamp_ns: Optional[int] = None\n\n    def _validate_key(self, key: str, key_type: str) -> None:\n        \"\"\"Validate that a key does not contain spaces, commas, or equals signs.\"\"\"\n        if not key:\n            raise InvalidKeyError(f\"{key_type} key cannot be empty\")\n        if \" \" in key:\n            raise InvalidKeyError(f\"{key_type} key '{key}' cannot contain spaces\")\n        if \",\" in key:\n            raise InvalidKeyError(f\"{key_type} key '{key}' cannot contain commas\")\n        if \"=\" in key:\n            raise InvalidKeyError(f\"{key_type} key '{key}' cannot contain equals signs\")\n\n    def _escape_measurement(self, value: str) -> str:\n        \"\"\"Escape characters in measurement names according to line protocol.\"\"\"\n        return value.replace(\",\", \"\\\\,\").replace(\" \", \"\\\\ \")\n\n    def _escape_tag_value(self, value: str) -> str:\n        \"\"\"Escape characters in tag values according to line protocol.\"\"\"\n        return (\n            value.replace(\"\\\\\", \"\\\\\\\\\")\n            .replace(\",\", \"\\\\,\")\n            .replace(\"=\", \"\\\\=\")\n            .replace(\" \", \"\\\\ \")\n        )\n\n    def _escape_field_key(self, value: str) -> str:\n        \"\"\"Escape characters in field keys according to line protocol.\"\"\"\n        return (\n            value.replace(\"\\\\\", \"\\\\\\\\\")","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_py_api/src/line_builder/line_builder.py#L29-L65","documentation":"The LineBuilder validates tag keys and field keys against line protocol restrictions before use. InfluxDB line protocol uses '=' to delimit key from value, so '=' in a key would corrupt the written line; this error rejects any tag or field key containing '='. Unlike spaces and commas, '=' in keys is not escapable in this builder, so it must be removed outright.","triggerScenarios":"Calling tag(), uint64_field(), int64_field(), float64_field(), string_field(), or bool_field() with a key containing an equals sign, e.g. builder.tag(\"a=b\", \"v\") or builder.string_field(\"status=ok\", \"x\").","commonSituations":"Building keys dynamically from HTTP headers, query strings, URL fragments, or label strings like 'key=value' copied from config files; parsing CSV headers that contain '='; joining name and unit with '=' (e.g. 'temp=C').","solutions":["Remove or replace '=' in the key before passing it to the builder, e.g. key.replace('=', ':') or key.split('=')[0].","If the '=' is semantically meaningful, move it into the tag VALUE or a field value, which are escaped by the builder.","Sanitize dynamic keys (headers, query params) at the ingestion boundary so '=' never reaches tag()/field calls."],"exampleFix":"// before\nbuilder.tag(\"region=us-east\", \"primary\")\n// after\nbuilder.tag(\"region:us-east\", \"primary\")  # or builder.tag(\"region\", \"us-east\")","handlingStrategy":"validation","validationCode":"def valid_key(key: str) -> bool:\n    return bool(key) and not any(c in key for c in ' ,=')","typeGuard":null,"tryCatchPattern":"try:\n    builder.tag(key, value)\nexcept InvalidKeyError:\n    key = key.replace('=', ':')\n    builder.tag(key, value)","preventionTips":["Sanitize dynamic keys (headers, query params, labels) for ' ,=' at ingestion boundaries.","Keep '='-containing data in tag/field values, which are escaped automatically.","Add a unit test asserting keys derived from real data never contain '='."],"tags":["validation","line-protocol","python","influxdb"],"backgroundTag":"invalid-identifier-format","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"}