Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a compilation error when running flux query with backslashes #158

Closed
taylanisikdemir opened this issue Jul 19, 2020 · 3 comments
Closed

Comments

@taylanisikdemir
Copy link

I'm using influxdb go client to run flux queries. I am having trouble filtering by a tag whose value is a windows file path with backslashes.

Query:

"from(bucket: \"7446077d\")
|> range(start: 2020-07-19T01:18:45.417Z, stop: 2020-07-19T01:19:05.417Z)
|> filter(fn: (r) => r._measurement == \"agent.anomaly2\")
|> filter(fn: (r) => r._field == \"value\")
|> filter(fn: (r) => r.source == \"C:\\Program Files\\Data\\a.log\")"

Error:
invalid (): compilation failed: expected RPAREN, got EOF

If I replace all backslashes with double backslashes it works fine.

"from(bucket: \"7446077d\")
|> range(start: 2020-07-19T01:01:43.336Z, stop: 2020-07-19T01:02:03.336Z)
|> filter(fn: (r) => r._measurement == \"agent.anomaly2\")
|> filter(fn: (r) => r._field == \"value\")
|> filter(fn: (r) => r.source == \"C:\\\\Program Files\\\\Data\\\\a.log\")"

Questions:

  1. Is this expected?
  2. Is my workaround safe?
  3. Are there other characters we should be escaping to avoid similar query compilation issues?

Note: I'm using an older version of go client (from April) but I am able to repro this issue with latest version v1.4.0

@sranka
Copy link
Contributor

sranka commented Jul 19, 2020

Yes, it is expected, a backslash is escaped in a flux string and then also in a go string. You can use golang's raw string literal to have less backslashes in a go string:

`from(bucket: "7446077d")
|> range(start: 2020-07-19T01:18:45.417Z, stop: 2020-07-19T01:19:05.417Z)
|> filter(fn: (r) => r._measurement == "agent.anomaly2")
|> filter(fn: (r) => r._field == "value")
|> filter(fn: (r) => r.source == "C:\\Program Files\\Data\\a.log")`

@taylanisikdemir
Copy link
Author

The example queries I shared are generated with raw string literals by the way. It still requires escaping the backslashes twice. Thanks for confirming the backslashes are escaped in a flux string as well as in a go string.

@vlastahajek
Copy link
Contributor

Escaping special chars will be handled by the Query parameters feature, once implemented. The issue for this is #146.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants