This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new a15d399ba77d [SPARK-45681][UI][FOLLOWUP] Check maybeErrorClass instead 
of maybeErrorClass.length
a15d399ba77d is described below

commit a15d399ba77d1fa23dda8ef71ab40938a72a4ad8
Author: Kent Yao <[email protected]>
AuthorDate: Fri Nov 17 13:01:57 2023 -0800

    [SPARK-45681][UI][FOLLOWUP] Check maybeErrorClass instead of 
maybeErrorClass.length
    
    ### What changes were proposed in this pull request?
    
    The `String.match` function may return null if no matches are found. This 
reverts the suggestion from 
https://github.com/apache/spark/pull/43547#discussion_r1375487690 to avoid 
`TypeError: Cannot read properties of null (reading 'length')`
    
    ### Why are the changes needed?
    
    bugfix
    
    ### Does this PR introduce _any_ user-facing change?
    
    no
    
    ### How was this patch tested?
    
    An UPCOMING javascript test framework for Spark UI
    
    ```javascript
    FAIL  tests/utils.test.js
      ✓ formatDuration (2 ms)
      ✓ formatBytes
      ✓ formatTimeMillis (1 ms)
      ✕ errorSummary (1 ms)
    
      ● errorSummary
    
        TypeError: Cannot read properties of null (reading 'length')
    
          254 |   const maybeErrorClass = errorMessage.match(ERROR_CLASS_REGEX);
          255 |   let errorClassOrBrief;
        > 256 |   if (maybeErrorClass.length === 2) {
              |                       ^
          257 |     errorClassOrBrief = maybeErrorClass[1];
          258 |   } else if (errorMessage.indexOf('\n') >= 0) {
          259 |     errorClassOrBrief = errorMessage.substring(0, 
errorMessage.indexOf('\n'));
    
          at length (utils.js:256:23)
          at Object.errorSummary (tests/utils.test.js:58:10)
    
    Test Suites: 1 failed, 1 total
    Tests:       1 failed, 3 passed, 4 total
    Snapshots:   0 total
    Time:        0.149 s, estimated 1 s
    ```
    
    ```javascript
     PASS  tests/utils.test.js
      ✓ formatDuration (1 ms)
      ✓ formatBytes (1 ms)
      ✓ formatTimeMillis (1 ms)
      ✓ errorSummary
    
    Test Suites: 1 passed, 1 total
    Tests:       4 passed, 4 total
    Snapshots:   0 total
    ```
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    no
    
    Closes #43872 from yaooqinn/SPARK-45681-F.
    
    Authored-by: Kent Yao <[email protected]>
    Signed-off-by: Dongjoon Hyun <[email protected]>
---
 core/src/main/resources/org/apache/spark/ui/static/utils.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/src/main/resources/org/apache/spark/ui/static/utils.js 
b/core/src/main/resources/org/apache/spark/ui/static/utils.js
index aa948e77b375..7b246756f3e3 100644
--- a/core/src/main/resources/org/apache/spark/ui/static/utils.js
+++ b/core/src/main/resources/org/apache/spark/ui/static/utils.js
@@ -251,7 +251,7 @@ function errorSummary(errorMessage) {
   let isMultiline = true;
   const maybeErrorClass = errorMessage.match(ERROR_CLASS_REGEX);
   let errorClassOrBrief;
-  if (maybeErrorClass.length === 2) {
+  if (maybeErrorClass) {
     errorClassOrBrief = maybeErrorClass[1];
   } else if (errorMessage.indexOf('\n') >= 0) {
     errorClassOrBrief = errorMessage.substring(0, errorMessage.indexOf('\n'));


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to