Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
9b305a03
Unverified
Commit
9b305a03
authored
9 months ago
by
Alexander Polyankin
Committed by
GitHub
9 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Add a try-catch for MBQL lib diagnoseExpression (#44628)
parent
1d5d9cb4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js
+19
-0
19 additions, 0 deletions
...enarios/question-reproductions/reproductions-3.cy.spec.js
frontend/src/metabase-lib/v1/expressions/diagnostics.ts
+21
-16
21 additions, 16 deletions
frontend/src/metabase-lib/v1/expressions/diagnostics.ts
with
40 additions
and
16 deletions
e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js
+
19
−
0
View file @
9b305a03
...
...
@@ -32,6 +32,8 @@ import {
appBar
,
openProductsTable
,
queryBuilderFooter
,
enterCustomColumnDetails
,
addCustomColumn
,
}
from
"
e2e/support/helpers
"
;
const
{
ORDERS
,
ORDERS_ID
,
PRODUCTS
}
=
SAMPLE_DATABASE
;
...
...
@@ -475,6 +477,23 @@ describe("issue 40435", () => {
});
});
describe
(
"
issue 41381
"
,
()
=>
{
beforeEach
(()
=>
{
restore
();
cy
.
signInAsNormalUser
();
});
it
(
"
should show an error message when adding a constant-only custom expression (metabase#41381)
"
,
()
=>
{
openOrdersTable
({
mode
:
"
notebook
"
});
addCustomColumn
();
enterCustomColumnDetails
({
formula
:
"
'Test'
"
,
name
:
"
Constant
"
});
popover
().
within
(()
=>
{
cy
.
findByText
(
"
Invalid expression
"
).
should
(
"
be.visible
"
);
cy
.
button
(
"
Done
"
).
should
(
"
be.disabled
"
);
});
});
});
describe
(
"
issue 42010 -- Unable to filter by mongo id
"
,
{
tags
:
"
@mongo
"
},
...
...
This diff is collapsed.
Click to expand it.
frontend/src/metabase-lib/v1/expressions/diagnostics.ts
+
21
−
16
View file @
9b305a03
...
...
@@ -144,22 +144,27 @@ export function diagnose({
const
expressionMode
:
Lib
.
ExpressionMode
=
startRuleToExpressionModeMapping
[
startRule
]
??
startRule
;
const
possibleError
=
Lib
.
diagnoseExpression
(
query
,
stageIndex
,
expressionMode
,
mbqlOrError
,
expressionPosition
,
);
if
(
possibleError
)
{
console
.
warn
(
"
diagnostic error
"
,
possibleError
.
message
);
// diagnoseExpression returns some messages which are user-friendly and some which are not.
// If the `friendly` flag is true, we can use the possibleError as-is; if not then use a generic message.
return
possibleError
.
friendly
?
possibleError
:
{
message
:
t
`Invalid expression`
};
try
{
const
possibleError
=
Lib
.
diagnoseExpression
(
query
,
stageIndex
,
expressionMode
,
mbqlOrError
,
expressionPosition
,
);
if
(
possibleError
)
{
console
.
warn
(
"
diagnostic error
"
,
possibleError
.
message
);
// diagnoseExpression returns some messages which are user-friendly and some which are not.
// If the `friendly` flag is true, we can use the possibleError as-is; if not then use a generic message.
return
possibleError
.
friendly
?
possibleError
:
{
message
:
t
`Invalid expression`
};
}
}
catch
(
error
)
{
console
.
warn
(
"
diagnostic error
"
,
error
);
return
{
message
:
t
`Invalid expression`
};
}
return
null
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment