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) -> {
Closes #
Proposed Changes
Rewrite
InfluxQLQueryAPIImpl.parseTags()to handle escaped commas and other reserved characters.Checklist
mvn testcompletes successfully