Skip to content

Commit 91b1040

Browse files
committed
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.
1 parent 8d1bb71 commit 91b1040

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

.github/workflows/cypress-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ name: Cypress E2E Tests
1717

1818
on:
1919
push:
20-
branches: [ "master" ]
20+
branches: [ "master", "2.x" ]
2121
paths:
2222
- 'storm-webapp/**'
2323
pull_request:
24-
branches: [ "master" ]
24+
branches: [ "master", "2.x" ]
2525
paths:
2626
- 'storm-webapp/**'
2727
workflow_dispatch:

storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/flux.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@
7070

7171
function parseAndRender() {
7272
var input = document.getElementById('taInput').value;
73-
var doc = jsyaml.load(input);
73+
var doc;
74+
try {
75+
doc = jsyaml.load(input);
76+
} catch (e) {
77+
// js-yaml >=5 throws on empty/comment-only input instead of
78+
// returning undefined (see migrate_v4_to_v5); treat as no document.
79+
return;
80+
}
7481
if(doc==null){
7582
return;
7683
}

0 commit comments

Comments
 (0)