-
Notifications
You must be signed in to change notification settings - Fork 2.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
[pkg/ottl] Fix bug where function names were allowed in comparison #33051
[pkg/ottl] Fix bug where function names were allowed in comparison #33051
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch.
@@ -1952,6 +1950,7 @@ func Test_parseCondition(t *testing.T) { | |||
{`One() == 1`, false}, | |||
{`test(fail())`, true}, | |||
{`Test()`, false}, | |||
{`"test" == Foo`, true}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the error look like now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like
statement has invalid syntax: 1:50: unexpected token "<EOF>" (expected "(" (Argument ("," Argument)*)? ")" Key*)
Which isn't the best, but at least it gives you hints where the issue is. I played around with keeping FunctionName
in value
and then doing a custom error when it is set, but that caused parsing issues bc value
is checked before FunctionName
in arguments
. It might be possible with some fancy negative lookaheads
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was playing with this today, mainly to understand it better and did some more or less crazy/dumb ideas but didn't managed to get any better error message than this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think overall we should try to avoid printing any grammar parsing errors since I think to most users they're incredibly cryptic. That said, this is still better than an error with "This is a bug in the OpenTelemetry Transformation Language" in it. I'd say let's get this in for now and circle back later.
Description:
Fix a bug where a condition like
"foo" = Bar
resulted in the errorno value field set. This is a bug in the OpenTelemetry Transformation Language
.Link to tracking Issue:
Closes #33048
Testing:
Updated unit tests