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

[pkg/ottl] Fix bug where function names were allowed in comparison #33051

Merged

Conversation

TylerHelmuth
Copy link
Member

Description:
Fix a bug where a condition like "foo" = Bar resulted in the error no value field set. This is a bug in the OpenTelemetry Transformation Language.

Link to tracking Issue:
Closes #33048

Testing:
Updated unit tests

Copy link
Contributor

@evan-bradley evan-bradley left a 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},
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Contributor

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

Copy link
Contributor

@evan-bradley evan-bradley May 17, 2024

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.

@TylerHelmuth TylerHelmuth merged commit 7aff95f into open-telemetry:main May 17, 2024
162 checks passed
@github-actions github-actions bot added this to the next release milestone May 17, 2024
@TylerHelmuth TylerHelmuth deleted the ottl-no-funcnames-in-conditions branch May 17, 2024 16:14
cparkins pushed a commit to AmadeusITGroup/opentelemetry-collector-contrib that referenced this pull request Jul 11, 2024
…pen-telemetry#33051)

**Description:** 
Fix a bug where a condition like `"foo" = Bar` resulted in the error `no
value field set. This is a bug in the OpenTelemetry Transformation
Language`.

**Link to tracking Issue:** <Issue number if applicable>
Closes
open-telemetry#33048

**Testing:** <Describe what testing was performed and which tests were
added.>
Updated unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants