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

String field with backslash quote results in unable to parse error #8728

Closed
danielnelson opened this issue Aug 22, 2017 · 10 comments
Closed

Comments

@danielnelson
Copy link
Contributor

Bug report

When sending a string field containing a literal \", I receive a unable to parse error if there is also a space in the field. I believe the line protocol is being escaped correctly, only the double quote character is backslash escaped within the quotes, the other backslashes are literals.

System info:

InfluxDB 1.3.3

Steps to reproduce:

curl -X POST 'http://localhost:8086/write?db=telegraf' --data 'foo bar="\\"howdy doody\\"" 1503364403083465901'

Expected behavior:

204 No Content

Actual behavior:

< HTTP/1.1 400 Bad Request
< Content-Type: application/json
< Request-Id: 5df3f53d-86da-11e7-8005-000000000000
< X-Influxdb-Version: 1.3.3
< Date: Tue, 22 Aug 2017 01:36:49 GMT
< Content-Length: 101
< 
{"error":"unable to parse 'foo bar=\"\\\\\"howdy doody\\\\\"\" 1503364403083465901': bad timestamp"}

Additional info:

This quoting allows for correct parsing: foo bar="\\\"howdy doody\\\"" 1503364403083465901, but is incorrect according to https://docs.influxdata.com/influxdb/v1.3/write_protocols/line_protocol_reference/#special-characters

This is the root cause of influxdata/telegraf#3142

@jwilder
Copy link
Contributor

jwilder commented Aug 23, 2017

It looks like you are escaping the slash before the quotes. Try:

curl -X POST 'http://localhost:8086/write?db=telegraf' --data 'foo bar="\"howdy doody\"" 1503364403083465902'

Or if the first slash is supposed to there, try:

curl -X POST 'http://localhost:8086/write?db=telegraf' --data 'foo bar="\\\"howdy doody\"" 1503364403083465901'
$ influx -database telegraf -execute "select * from foo"
name: foo
time                bar
----                ---
1503364403083465901 \"howdy doody"
1503364403083465902 "howdy doody"

@danielnelson
Copy link
Contributor Author

The backslash and quote are both supposed to be there. I can definitely change Telegraf to escape/unescape backslashes within string fields, but I want to make sure it is correct since this is not what is documented and it needs to work with Kapacitor and the Telegraf read side.

@jwilder
Copy link
Contributor

jwilder commented Aug 23, 2017

It looks like those docs are incorrect for strings escaping (and have been since 0.9.4). Backslashes need to be escaped within string fields. Here are some example tests we have for that case:

https://github.com/influxdata/influxdb/blob/master/models/points_test.go#L1300

This is the commit that added support for backslashes in strings: 6ca7970#diff-4fbf62c788a5b69da86ec473a6f13f22

@gzll
Copy link

gzll commented Sep 6, 2017

@e-dard
Copy link
Contributor

e-dard commented Oct 12, 2017

I'm assuming this is now resolved.

@e-dard e-dard closed this as completed Oct 12, 2017
@danielnelson
Copy link
Contributor Author

I think there should be a documentation update to close this.

@danielnelson danielnelson reopened this Oct 12, 2017
@e-dard
Copy link
Contributor

e-dard commented Oct 12, 2017

@danielnelson an issue should be opened on the docs repo to track this.

@sanchomuzax
Copy link

How can I use whitespace in BASH variable?

Example:

a="foo,bar=howdy\ doody"
curl -i -XPOST 'http://localhost:8086/write?db=test' --data-binary $a' value=1'

HTTP/1.1 400 Bad Request
Content-Type: application/json
Request-Id: 3c146692-f60d-11e7-ac46-000000000000
X-Influxdb-Version: 1.3.7
Date: Wed, 10 Jan 2018 13:50:36 GMT
Content-Length: 68

{"error":"unable to parse 'foo,bar=howdy\\\u0000': missing fields"}
curl: (6) Could not resolve host: doody value=1; Name or service not known

@stale
Copy link

stale bot commented Jul 24, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 24, 2019
@stale
Copy link

stale bot commented Jul 31, 2019

This issue has been automatically closed because it has not had recent activity. Please reopen if this issue is still important to you. Thank you for your contributions.

@stale stale bot closed this as completed Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants