Commit 02d95c0
authored
fix(crashtracking): handle new lines in client submitted exception message (#1836)
# What does this PR do?
Escapes new lines from API consumer submitted unhandled exception message, then unescapes it when writing the report. This is necessary, because API consumers can submit arbitrary exception messages, and if they contain new lines, the receiver state machine parsing breaks as it depends on chunks of data being sent as lines.
# Motivation
This [crash log](https://app.datadoghq.com/logs?query=service%3Ainstrumentation-telemetry-data%20%28%40tags.severity%3Acrash%20OR%20severity%3Acrash%20OR%20signum%3A%2A%20OR%20%40error.is_crash%3Atrue%29%20-%40metadata.tags%3A%22crash_datadog%3Atrue%22%20-%22Process%20was%20terminated%20due%20to%20an%20unhandled%20exception%22%20source%3Aruby&agg_m=count&agg_m_source=base&agg_q=%40metadata.family&agg_t=count&cf_lbyyhhwhyjj5l3rs65cb3w=aiugo4c9e5i04jdlqn4i&clustering_pattern_field_path=message&cols=source%2C%40tracer_version%2C%40language_version%2C%40org&event=AwAAAZ0xDw1VSu-b3AAAABhBWjB4RHcxVkFBQkxSUWRlaE1Rb1B3QUEAAAAkZDE5ZDMxMGYtNGI0OC00NDQ5LWI5NmMtY2QwZjJkNjE0NDExAAAfZw&flat_group_bys=true&fromUser=true&messageDisplay=inline&refresh_mode=sliding&sort_m=count&sort_t=count&storage=live&stream_sort=desc&top_n=10&top_o=top&view=spans&viz=stream&x_missing=true&from_ts=1772048747006&to_ts=1774640747006&live=true) has no message because the exception message being sent has [new lines](https://github.com/rails/rails/blob/8ec9ba082fd08f7db0c601056d86356b0b5e4d25/activerecord/lib/active_record/errors.rb#L354-L364) in it
# Additional Notes
I've looked at other places where API consumers submit raw strings that we just pass in raw, and I cannot find other plausible places where this could be an issue
# How to test the change?
Bin_test updated to include a new line in the input to the unhandled exception API
Co-authored-by: gyuheon.oh <gyuheon.oh@datadoghq.com>1 parent f7427db commit 02d95c0
4 files changed
Lines changed: 13 additions & 4 deletions
File tree
- bin_tests
- src/bin
- tests
- libdd-crashtracker/src
- collector
- receiver
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
424 | | - | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
425 | 433 | | |
426 | 434 | | |
427 | 435 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
| 272 | + | |
272 | 273 | | |
273 | 274 | | |
274 | 275 | | |
| |||
0 commit comments