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

VRL coalesce assignment panics #13461

Closed
fuchsnj opened this issue Jul 6, 2022 · 1 comment · Fixed by #14114
Closed

VRL coalesce assignment panics #13461

fuchsnj opened this issue Jul 6, 2022 · 1 comment · Fixed by #14114
Assignees
Labels
meta: regression This issue represents a regression type: bug A code related bug. vrl: compiler Changes made to the VRL compiler.

Comments

@fuchsnj
Copy link
Member

fuchsnj commented Jul 6, 2022

A note for the community

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Problem

The following VRL code causes a panic

.(a|b) = 5
thread 'main' panicked at 'attempt to subtract with overflow', lib/vrl/compiler/src/expression/assignment.rs:250:37

I suspect this was caused by #13317

It seems to work fine with 0.23

Version

master / 2d62397

@fuchsnj fuchsnj added type: bug A code related bug. vrl: compiler Changes made to the VRL compiler. labels Jul 6, 2022
@JeanMertz JeanMertz self-assigned this Jul 12, 2022
@fuchsnj
Copy link
Member Author

fuchsnj commented Aug 19, 2022

The following also panics

.@foo = 5

I believe the root cause is that the diagnostic code is assuming that length of string generated from the Display impl of FieldBuf is identical to the raw source code, which isn't necessarily true.

In the above case, the Display implementation is incorrect and unnecessarily quotes the field name, which makes the string longer than the source code, causing an underflow / panic.

I would also consider it valid for the Display implementation to remove quotes if the user unnecessarily add quotes. The diagnostics probably shouldn't rely on this for calculating spans.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta: regression This issue represents a regression type: bug A code related bug. vrl: compiler Changes made to the VRL compiler.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants