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] Parsing of named arguments is whitespace dependent #27638

Closed
TylerHelmuth opened this issue Oct 11, 2023 · 2 comments · Fixed by #28511
Closed

[pkg/ottl] Parsing of named arguments is whitespace dependent #27638

TylerHelmuth opened this issue Oct 11, 2023 · 2 comments · Fixed by #28511
Labels
bug Something isn't working pkg/ottl priority:p2 Medium

Comments

@TylerHelmuth
Copy link
Member

TylerHelmuth commented Oct 11, 2023

Component(s)

pkg/ottl

What happened?

Description

While testing out some optional parameter situations I discovered that the named argument parsing is whitespace dependent. This is in contrast with the rest of OTTL which does not depend on whitespace. I am not yet sure why this is happening as the grammar/tokens seem correct. The whitespace in (@(Lowercase(Uppercase | Lowercase)*) Equal)? is ignored by the parser and the Equal token cannot appear in Lowercase or Uppercase.

Steps to Reproduce

I added this test to parser_test.go:

{
  name:      "editor with named arg",
  statement: `set(name="foo")`,
  expected: &parsedStatement{
    Editor: editor{
      Function: "set",
      Arguments: []argument{
        {
          Name: "name",
          Value: value{
            String: ottltest.Strp("foo"),
          },
        },
      },
    },
    WhereClause: nil,
  },
},

Expected Result

Test passed

Actual Result

Got an error parsing the statement. No error occurs if the statement is written as set(name = "foo")

@TylerHelmuth TylerHelmuth added bug Something isn't working needs triage New item requiring triage priority:p2 Medium pkg/ottl and removed needs triage New item requiring triage labels Oct 11, 2023
@TylerHelmuth
Copy link
Member Author

Additional testing revealed that set(name= "foo") passed

@TylerHelmuth
Copy link
Member Author

Turns out that the Equal token is the issue. In order to not match ==, the token is written as =[^=], which means that it must have at least 1 character after the equal.

evan-bradley pushed a commit that referenced this issue Oct 24, 2023
**Description:** 
Fixes an issue with the grammar where named parameters had to have a
space after the `=`.

**Link to tracking Issue:**
Closes
#27638

**Testing:** 
Added a new unit test
sigilioso pushed a commit to carlossscastro/opentelemetry-collector-contrib that referenced this issue Oct 27, 2023
**Description:** 
Fixes an issue with the grammar where named parameters had to have a
space after the `=`.

**Link to tracking Issue:**
Closes
open-telemetry#27638

**Testing:** 
Added a new unit test
jmsnll pushed a commit to jmsnll/opentelemetry-collector-contrib that referenced this issue Nov 12, 2023
**Description:** 
Fixes an issue with the grammar where named parameters had to have a
space after the `=`.

**Link to tracking Issue:**
Closes
open-telemetry#27638

**Testing:** 
Added a new unit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg/ottl priority:p2 Medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant