fix(webapp): guard Flux viewer against js-yaml 5.x empty-input throw (2.x)#8890
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
2.x companion to #8889.
2.x already merged js-yaml 5.2.0 (#8863), which carries a latent runtime bug: js-yaml 5.x changed
load('')to throwYAMLException: expected a document, but the input is emptyinstead of returningundefined(see the v4→v5 migration guide).The Flux Topology Viewer (
flux.html) callsparseAndRender()on page load while the textarea holds only# YAML Definition, sojsyaml.load(input)now throws before theif (doc == null) return;guard — the viewer fails to render.This slipped through on 2.x because
cypress-tests.ymlonly triggered onmaster, so 2.x PRs never ran the e2e suite that catches it (this is exactly what happened with #8863).Fix
jsyaml.load()intry/catch, treating empty/comment-only/malformed input as "no document".cypress-tests.ymlto also run on2.x.