Conversation
…s and backslashes.
There was a problem hiding this comment.
Pull request overview
This PR updates the InfluxQL CSV parsing logic to correctly handle tagsets containing escaped commas (and other escaped reserved characters) in the tags column, and adds test coverage for these cases.
Changes:
- Rewrote
InfluxQLQueryApiImpl.parseTags()to parse tagsets character-by-character instead of splitting on,and=. - Added a new unit test covering multiple escaped-comma / escaped-reserved-character tag scenarios.
- Minor formatting adjustment to the
CSVParserconstruction.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java |
Replaces naive tag splitting with an escape-aware parser for tag key/value extraction. |
client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java |
Adds coverage for escaped commas/reserved characters in tags returned from InfluxQL CSV responses. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java
Outdated
Show resolved
Hide resolved
client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java
Outdated
Show resolved
Hide resolved
client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java
Show resolved
Hide resolved
client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR updates InfluxQL CSV result parsing to correctly handle tagsets that contain escaped commas (and other escaped reserved characters), preventing incorrect tag splitting when reserved characters appear in tag keys/values.
Changes:
- Rewrote
InfluxQLQueryApiImpl.parseTags()to parse tagsets character-by-character with escape awareness. - Added a focused regression test covering tagsets with escaped commas/spaces/equals in both keys and values.
- Minor formatting adjustment to the
CSVParserconstruction for readability.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java | Replaces naive split()-based tag parsing with an escape-aware parser. |
| client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java | Adds coverage for tag parsing when commas (and other reserved chars) are escaped in tagsets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java
Outdated
Show resolved
Hide resolved
client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR fixes InfluxQL CSV tagset parsing so tag key/value pairs containing escaped commas (and other escaped reserved characters) are correctly split into Series.getTags() without breaking on escaped delimiters.
Changes:
- Rewrote
InfluxQLQueryApiImpl.parseTags()to parse tagsets with an escape-aware state machine (instead of naivesplit). - Added a dedicated regression test covering escaped commas/spaces/equals in both tag keys and values (plus a “legacy broken tags” case).
- Minor formatting adjustment to the
CSVParserconstruction for readability.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java | Implements escape-aware tag parsing to avoid incorrect splitting on escaped commas/equals/spaces. |
| client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java | Adds regression coverage for multiple escaped-tag patterns and validates parsed tags/columns/value extraction behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Parser is safe and robust. GTG with CHANGELOG entry and if checks pass.
I tried edge cases tests (see bellow, for your consideration whether to add or not), they pass OK.
diff --git a/client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java b/client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java
index ca587ab7c0..9cc8fbe05a 100644
--- a/client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java
+++ b/client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java
@@ -63,6 +63,38 @@ class InfluxQLQueryApiImplTest {
return map;
}
+ private static void assertParsedTags(
+ @Nonnull final String rawTags,
+ @Nonnull final Map<String, String> expectedTags
+ ) throws IOException {
+
+ StringReader reader = new StringReader(
+ "name,tags,time,value\n" +
+ "m,\"" + rawTags + "\",1,1\n"
+ );
+ InfluxQLQueryResult result = InfluxQLQueryApiImpl.readInfluxQLResult(reader, NO_CANCELLING, null);
+
+ Assertions.assertThat(result.getResults()).hasSize(1);
+ Assertions.assertThat(result.getResults().get(0).getSeries()).hasSize(1);
+ Assertions.assertThat(result.getResults().get(0).getSeries().get(0).getTags()).isEqualTo(expectedTags);
+ }
+
+ @Test
+ void readInfluxQLResultWithMalformedAndBoundaryTagCases() throws IOException {
+ assertParsedTags("", mapOf());
+ assertParsedTags("host=", mapOf("host", ""));
+ assertParsedTags("host=a,host=b", mapOf("host", "b"));
+ assertParsedTags("host=a,broken", mapOf("host", "a"));
+ assertParsedTags("=a,host=b", mapOf("host", "b"));
+ assertParsedTags("host=a,", mapOf("host", "a"));
+ assertParsedTags(",host=a", mapOf(",host", "a"));
+ assertParsedTags("a=1,,b=2", mapOf("a", "1", ",b", "2"));
+ assertParsedTags("a=foo\\", mapOf("a", "foo\\"));
+ assertParsedTags("k\\==v\\=1", mapOf("k\\=", "v\\=1"));
+ assertParsedTags("k\\,x=v\\,y,b=2", mapOf("k\\,x", "v\\,y", "b", "2"));
+ assertParsedTags("k\\=x", mapOf());
+ }
+
@Test
void readInfluxQLResultWithTagCommas() throws IOException {
InfluxQLQueryResult.Series.ValueExtractor extractValue = (columnName, rawValue, resultIndex, seriesName) -> {
| assertParsedTags("host=a,broken", mapOf("host", "a")); | ||
| assertParsedTags("=a,host=b", mapOf("host", "b")); | ||
| assertParsedTags("host=a,", mapOf("host", "a")); | ||
| assertParsedTags(",host=a", mapOf(",host", "a")); |
There was a problem hiding this comment.
Adds another edge case
| assertParsedTags(",host=a", mapOf(",host", "a")); | |
| assertParsedTags("host=a\\,b", mapOf("host", "a\\,b")); | |
| assertParsedTags(",host=a", mapOf(",host", "a")); |
| } | ||
|
|
||
| if (firstEscaped) { | ||
| firstEscaped = false; |
There was a problem hiding this comment.
This is what Codex suggests to fix changes introduced in 7fe6761:
High: Possible tag corruption for single-escaped delimiters in parser state machine.
At InfluxQLQueryApiImpl.java:226, when firstEscaped is true, the next non-\ character is skipped entirely (continue), not preserved.
This means inputs like host=a,b (single backslash before comma) become a\b (comma dropped), so tags are parsed incorrectly even though the exception is avoided.
| firstEscaped = false; | |
| if (inValue) { | |
| currentValue.append(c); | |
| } else { | |
| currentKey.append(c); | |
| } | |
| firstEscaped = false; |
| .addTag("host", "A") | ||
| .addTag("region", "west") | ||
| .addTag("location", "vancouver\\,\\ BC") | ||
| .addTag("model\\,\\ uid","droid\\,\\ C3PO") |
There was a problem hiding this comment.
Codex finding: Medium: New IT test does not reflect normal client write usage for comma-containing tags.
In ITInfluxQLQueryApi.java:108 and ITInfluxQLQueryApi.java:109, tags are written already escaped ("vancouver\,\ BC", "model\,\ uid").
With Point.addTag(...), callers typically pass raw values ("vancouver, BC"), and escaping is handled during line-protocol serialization. This test can pass while missing real-world parser cases.
Such raw values could be added to match more real-world cases, imho.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## hotfix/v6.10.1 #862 +/- ##
====================================================
+ Coverage 88.36% 88.38% +0.01%
Complexity 777 777
====================================================
Files 172 172
Lines 7022 7067 +45
Branches 382 393 +11
====================================================
+ Hits 6205 6246 +41
- Misses 698 700 +2
- Partials 119 121 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bednar
left a comment
There was a problem hiding this comment.
All versions in pom.xml should be: 6.10.1-SNAPSHOT and all tags should be HEAD.
| <developerConnection>scm:git:git@github.com:influxdata/influxdb-client-java.git</developerConnection> | ||
| <url>https://github.com/influxdata/influxdb-client-java/tree/master</url> | ||
| <tag>v6.10.0</tag> | ||
| <tag>v6.10.1</tag> |
There was a problem hiding this comment.
Here should be: <tag>HEAD</tag>
Closes #
Proposed Changes
Rewrite
InfluxQLQueryAPIImpl.parseTags()to handle escaped commas and other reserved characters.Checklist
mvn testcompletes successfully