-
- Downloads
Ensure :error is present for frontend (#23346)
* Ensure :error is present for frontend The frontend checks for a string at "error" to determine if there's an error or not. Any error that lacks a message (`(.getMessage e) = nil`) will report as a successful query with no results. This was hard to reproduce at first because java 14+ added a nice error message to NPEs in [JEP-358](https://openjdk.org/jeps/358). ```java ;; java 11 jshell> HashSet x = null; x ==> null jshell> x.contains(3); | Exception java.lang.NullPointerException | at (#2:1) jshell> ;; java 17 jshell> HashSet x = null; x ==> null jshell> x.contains(3); | Exception java.lang.NullPointerException: Cannot invoke "java.util.HashSet.contains(Object)" because "REPL.$JShell$11.x" is null | at (#4:1) ``` ```clojure ;; java 17 catch-exceptions=> (let [x nil] (x 3)) Execution error (NullPointerException) at metabase.query-processor.middleware.catch-exceptions/eval130385 (REPL:41). Cannot invoke "clojure.lang.IFn.invoke(Object)" because "x" is null ;; java 11 catch-exceptions=> (let [x nil] (x 3)) Execution error (NullPointerException) at metabase.driver.sql.parameters.substitution/eval118508 (REPL:17). null ``` Here are the responses to the FE edited to the relevant bits: ```javascript // objects are edited for clarity/brevity: // from java-11 { "error_type": "qp", "status": "failed", "class": "class java.lang.NullPointerException", "stacktrace": [...], "error": null, // <---- the FE ignores all of the other data and only sees this } // vs java-17 { "error_type": "qp", "status": "failed", "class": "class java.lang.NullPointerException", "stacktrace": [...], "error": "Cannot invoke \"clojure.lang.IFn.invoke(Object)\" because \"to_period\" is null",, } ``` Also, note that we were still logging > ERROR middleware.catch-exceptions :: Error processing query: null because we were looking for `(:error format-exception)` instead of `(:error formatted-exception)`. `format-exception` is a multimethod and lookup on non-associative things will happily return nil. * Tests
Showing
- src/metabase/query_processor/middleware/catch_exceptions.clj 8 additions, 2 deletionssrc/metabase/query_processor/middleware/catch_exceptions.clj
- test/metabase/query_processor/middleware/catch_exceptions_test.clj 43 additions, 30 deletions...base/query_processor/middleware/catch_exceptions_test.clj
Please register or sign in to comment