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

Custom Expression name containing brackets ([ or ]) can break the UI #15316

Closed
flamber opened this issue Mar 24, 2021 · 5 comments · Fixed by #20927
Closed

Custom Expression name containing brackets ([ or ]) can break the UI #15316

flamber opened this issue Mar 24, 2021 · 5 comments · Fixed by #20927
Assignees
Labels
.Frontend Priority:P2 Average run of the mill bug Querying/Notebook/Custom Expression .Reproduced Issues reproduced in test (usually Cypress) Type:Bug Product defects
Milestone

Comments

@flamber
Copy link
Contributor

flamber commented Mar 24, 2021

Describe the bug
When a Custom Expression uses a name containing brackets ([ or ]), then autocomplete dropdown stops working and forcefully trying to use that expression again in another expression will break the UI until browser refresh (or show "Something went wrong").

To Reproduce

  1. Custom question > Sample Dataset > Orders
  2. Custom Column formula 1 + 1 with the name MyCC [2021]
  3. Summarize > Custom Expression > type Sum([ notice there's no field dropdown
    image
  4. Summarize > Sum of > pick the MyCC [2021]
  5. Click the metric again, and click the title to go back to list of metrics and click Custom Expression - the UI is now broken and requires a browser refresh to function again (on upcoming 0.39 master, it will reset everything done in the Notebook and show "Something went wrong" in the lower-right corner)
    image

There are a lot of browser console errors

Firefox: TypeError: e._wrapperState is null
Chrome: Uncaught Error: String currently can't contain brackets: MyCC [2021]      <-- hey, why didn't it tell me that in the UI?

Information about your Metabase Installation:
Tested 0.38.2 and master

Severity
Giving P2, since it breaks UI (or clears everything on master), even though it's an easy workaround - don't use brackets.
Are there other characters that could cause similar problem?

@flamber flamber added Type:Bug Product defects Priority:P2 Average run of the mill bug Querying/Notebook Items specific to the Custom/Notebook query builder labels Mar 24, 2021
nemanjaglumac added a commit that referenced this issue Mar 30, 2021
@nemanjaglumac nemanjaglumac added the .Reproduced Issues reproduced in test (usually Cypress) label Mar 30, 2021
@howonlee howonlee self-assigned this Apr 5, 2021
@howonlee
Copy link
Contributor

howonlee commented Apr 5, 2021

confirming different-but-same brokenness for parens

@ariya
Copy link
Contributor

ariya commented May 5, 2021

This is currently the limitation of the lexer used in the Chevrotain-based parser, it does not understand a field reference that contains brackets or parentheses or other special characters (which must be escaped), e.g. [MyCC \[2021\]].

@ariya
Copy link
Contributor

ariya commented May 27, 2021

Now that I think about this problem, maybe the solution is to prevent the use of these special characters as the name of any custom column. It's going to cumbersome anyway to use a name that has brackets, even if character escaping is supported.

Thus, the plan is: if the custom column name contains one ore more special characters, show an error message and don't let the user continue.

Does that sound like a good compromise?

@howonlee
Copy link
Contributor

howonlee commented May 27, 2021

Doesn't this one affect non-custom columns too? Quote delimited columns in postgres can have anything - brackets, emoji...

@flamber
Copy link
Contributor Author

flamber commented May 27, 2021

@ariya Sounds great, but as @howonlee mentions - this can also happen via the display name changed in Admin > Data Model.
Just tried Subtotal [2010] - then no suggestions are shown, when trying to summarize and console borks with:
Error: String currently can't contain brackets: Subtotal [2010]

This was referenced May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.Frontend Priority:P2 Average run of the mill bug Querying/Notebook/Custom Expression .Reproduced Issues reproduced in test (usually Cypress) Type:Bug Product defects
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants