From 47784cba5d76c6da82bc6b70e63a611d743dc5af Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Wed, 1 Jul 2026 15:43:22 +0200 Subject: [PATCH] fix(webapp): guard Flux viewer against js-yaml 5.x empty-input throw js-yaml 5.x (merged on 2.x via #8863) changed load('') to throw a YAMLException ('expected a document, but the input is empty') instead of returning undefined (see js-yaml migrate_v4_to_v5). The Flux Topology Viewer calls parseAndRender() on page load while the textarea holds only a comment (# YAML Definition), so jsyaml.load() now throws before the existing if(doc==null) guard, breaking the viewer at runtime. This latent bug shipped untested on 2.x because cypress-tests.yml was scoped to master only, so 2.x PRs never ran the e2e suite. Wrap the load in try/catch and treat empty/comment-only or malformed input as 'no document', and broaden cypress-tests.yml to run on 2.x. --- .github/workflows/cypress-tests.yml | 4 ++-- .../java/org/apache/storm/daemon/ui/WEB-INF/flux.html | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cypress-tests.yml b/.github/workflows/cypress-tests.yml index fc2c6007eae..50b71368c74 100644 --- a/.github/workflows/cypress-tests.yml +++ b/.github/workflows/cypress-tests.yml @@ -17,11 +17,11 @@ name: Cypress E2E Tests on: push: - branches: [ "master" ] + branches: [ "master", "2.x" ] paths: - 'storm-webapp/**' pull_request: - branches: [ "master" ] + branches: [ "master", "2.x" ] paths: - 'storm-webapp/**' workflow_dispatch: diff --git a/storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/flux.html b/storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/flux.html index ad676c17a78..9d869992135 100644 --- a/storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/flux.html +++ b/storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/flux.html @@ -70,7 +70,14 @@ function parseAndRender() { var input = document.getElementById('taInput').value; - var doc = jsyaml.load(input); + var doc; + try { + doc = jsyaml.load(input); + } catch (e) { + // js-yaml >=5 throws on empty/comment-only input instead of + // returning undefined (see migrate_v4_to_v5); treat as no document. + return; + } if(doc==null){ return; }