-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Panic on string fields with unescaped quotes: Slice bounds out of range #3326
Comments
Thanks for opening the bug report, would you be able to send me an example of the line protocol that is causing the crash? |
This works: This doesn't: |
I am unable to reproduce on Linux publishing running:
Do you have just a single line in each message? I know there are some issues with DOS line endings. Perhaps you can try publishing with this command? |
There's just a single line in each message. Messages are being published out of ActiveMQ through the MQTT endpoint, also running on Windows. I'll see if there are any DOS line endings in the lines that get published to telegraf and replace them. |
It fails using both ActiveMQ and Mosquitto running on Windows. Hidden characters have also been removed from the strings. I'll try running Mosquitto on Linux. |
I could make you a build with an extra logging statement that you could run in Windows to capture the message as Telegraf sees it, I think that would give us the info we need. |
Thanks, that would be helpful. I installed Mosquitto on Ubuntu and used that as the broker. It still causes that same error. |
This build should log one line per message telegraf-1.5.0~e1468b8_windows_amd64.zip |
Here's the log file using the new build. |
Thank you, I can reproduce the crash with this line so it should be fairly straightforward to fix:
The line should be rejected as invalid line protocol, because the field needs internal double quotes escaped (make sure to escape -text="Tracker error: (-1) - Failed to identify tracker type from "172.18.111.31".Please check network settings to verify Tracker @ "172.18.111.31" is reachable. If tracker is in WiFi mode, make sure you are connected to the tracker's SSID. Alternately, use the "
+text="Tracker error: (-1) - Failed to identify tracker type from \"172.18.111.31\".Please check network settings to verify Tracker @ \"172.18.111.31\" is reachable. If tracker is in WiFi mode, make sure you are connected to the tracker's SSID. Alternately, use the " |
Thank you. Internal double quotes need to be escaped as well. |
Let's leave this open until the panic is fixed. |
Before this change Fields() method on a metric parsed from a line with unescaped quotes could panic. This change makes such line unparseable. Fixes #3326
Before this change Fields() method on a metric parsed from a line with unescaped quotes could panic. This change makes such line unparseable. Fixes influxdata#3326
Before this change Fields() method on a metric parsed from a line with unescaped quotes could panic. This change makes such line unparseable. Fixes #3326
Directions
GitHub Issues are reserved for actionable bug reports and feature requests.
General questions should be asked at the InfluxData Community site.
Before opening an issue, search for similar bug reports or feature requests on GitHub Issues.
If no similar issue can be found, fill out either the "Bug Report" or the "Feature Request" section below.
Erase the other section and everything on and above this line.
Please note, the quickest way to fix a bug is to open a Pull Request.
Bug report
C:\telegraf-1.4.0>telegraf.exe -config telegraf.conf
panic: runtime error: slice bounds out of range
goroutine 73 [running]:
github.com/influxdata/telegraf/metric.(*metric).Fields(0xc04261f780, 0xc042635580)
/home/ubuntu/telegraf-build/src/github.com/influxdata/telegraf/metric/metric.go:356 +0x5cf
github.com/influxdata/telegraf/plugins/inputs/mqtt_consumer.(*MQTTConsumer).receiver(0xc0423a4b00)
/home/ubuntu/telegraf-build/src/github.com/influxdata/telegraf/plugins/inputs/mqtt_consumer/mqtt_consumer.go:176 +0x2e2
created by github.com/influxdata/telegraf/plugins/inputs/mqtt_consumer.(*MQTTConsumer).Start
/home/ubuntu/telegraf-build/src/github.com/influxdata/telegraf/plugins/inputs/mqtt_consumer/mqtt_consumer.go:131 +0x225
Relevant telegraf.conf:
System info:
Telegraf 1.4.0, Windows 10
Steps to reproduce:
Send an InfluxDB line protocol line with field values with both strings and floats. It works fine when the field values are surrounded with double quotes to be treated as a string, but breaks when float field values have no double quotes.
Expected behavior:
No error and the line gets processed, Telegraf keeps running
Actual behavior:
Telegraf quits and produces this error message. No additional errors are added to the log.
The text was updated successfully, but these errors were encountered: