influxdata / influxdata/influxdb-java
the WriteApi does not check whether a tag value cotains unauthorized characters ("\n","\r"...)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 469
- PR merge metrics
- No merged PRs in 30d
Description
InfluxDB has some restrictions on tag values : they cannot contain some characters such as: line feed (\n), carriage return (\r). Currently, the Java client library does not check whether values of tags are safe (free of unauthorized characters) before writing them into InfluxDB.
For example, I have a measurement classe called `Temperature`, and it contains a tag field `location`. When I put `location="mad\nrid"` and I write it using `WriteApi`, it will throw the following exception: `partial write: unable to parse 'temperature,location=mad': missing fields dropped=0`. So a partial write will be done in the influxDB database: a new measurement `rid` will be mistakenly created, and it will contain only a part of the write.
If a tag value contains '\r', the java client will not even throw an exception, and it will perform an incorrect write into the database.
I think it would be really useful to add a method that ensures that tag values are correct before sending them to InfluxDB through the line protocol, in order to avoid incorrect writes and anomalous behaviors.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the WriteApi path that serializes tag values into InfluxDB line protocol. Verify how values containing line feed and carriage return are handled, then add validation so unsafe values cannot produce partial or incorrect writes; use the existing WriteApi tests, if present, to cover both characters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100