diff --git a/lib/vector-vrl/web-playground/public/README.md b/lib/vector-vrl/web-playground/public/README.md index b042c0f4a26db..9354b77321205 100644 --- a/lib/vector-vrl/web-playground/public/README.md +++ b/lib/vector-vrl/web-playground/public/README.md @@ -53,15 +53,16 @@ Some functions of VRL are not supported or don't work as expected at the moment due to WASM limitations with some Rust crates, in the future we will modify the functions so that they are supported. -List of functions that aren't supported at the moment: - -- `log()` -- `decrypt()` -- `encrypt()` -- `get_hostname()` -- `parse_groks()` -- `random_bytes()` -- `reverse_dns()` +List of functions that aren't supported at the moment. All of them exist, +but they will either error (enrichment functions) or abort (all the others) at runtime. + +- `log` +- `get_hostname` +- `parse_grok` +- `parse_groks` +- `reverse_dns` +- `find_enrichment_table_records` +- `get_enrichment_table_record` Functions from VRL stdlib that are currently not supported can be found with this [issue filter][vrl-wasm-unsupported-filter] diff --git a/lib/vector-vrl/web-playground/public/index.js b/lib/vector-vrl/web-playground/public/index.js index 6f69af1c6ab98..2a1d6aecb7ff5 100644 --- a/lib/vector-vrl/web-playground/public/index.js +++ b/lib/vector-vrl/web-playground/public/index.js @@ -100,13 +100,29 @@ export class VrlWebPlayground { program: this.programEditor.getValue(), event: this.eventEditor.getModel().getLinesContent().join("\n"), is_jsonl: true, + error: null, }; } - return { - program: this.programEditor.getValue(), - event: JSON.parse((this.eventEditor.getValue().length == 0) ? "{}" : this.eventEditor.getValue()), - is_jsonl: false, - }; + + const editorValue = this.eventEditor.getValue(); + try { + return { + program: this.programEditor.getValue(), + event: JSON.parse((editorValue.length === 0) ? "{}" : editorValue), + is_jsonl: false, + error: null, + }; + } + catch (error) { + console.error(error); + return { + program: this.programEditor.getValue(), + event: null, + is_jsonl: false, + error: `Could not parse JSON event:\n${editorValue}`, + }; + } + return state; } disableJsonLinting() { @@ -168,6 +184,11 @@ export class VrlWebPlayground { if (input == null) { input = this.getState(); } + if (input.error) { + this.disableJsonLinting(); + this.outputEditor.setValue(input.error); + return input; + } let res = this.run_vrl(input); console.log("[DEBUG::handleRunCode()] Printing out res: ", res); diff --git a/lib/vector-vrl/web-playground/public/package.json b/lib/vector-vrl/web-playground/public/package.json index e8bfd02f7d3ca..fc6889020fde3 100644 --- a/lib/vector-vrl/web-playground/public/package.json +++ b/lib/vector-vrl/web-playground/public/package.json @@ -8,7 +8,5 @@ ], "module": "vector_vrl_web_playground.js", "types": "vector_vrl_web_playground.d.ts", - "sideEffects": [ - "./snippets/*" - ] + "sideEffects": false }