Commit 8519cb1 1 parent bc86222 commit 8519cb1 Copy full SHA for 8519cb1
File tree 3 files changed +37
-17
lines changed
lib/vector-vrl/web-playground/public
3 files changed +37
-17
lines changed Original file line number Diff line number Diff line change @@ -53,15 +53,16 @@ Some functions of VRL are not supported or don't work as expected at the
53
53
moment due to WASM limitations with some Rust crates, in
54
54
the future we will modify the functions so that they are supported.
55
55
56
- List of functions that aren't supported at the moment:
57
-
58
- - ` log() `
59
- - ` decrypt() `
60
- - ` encrypt() `
61
- - ` get_hostname() `
62
- - ` parse_groks() `
63
- - ` random_bytes() `
64
- - ` reverse_dns() `
56
+ List of functions that aren't supported at the moment. All of them exist,
57
+ but they will either error (enrichment functions) or abort (all the others) at runtime.
58
+
59
+ - ` log `
60
+ - ` get_hostname `
61
+ - ` parse_grok `
62
+ - ` parse_groks `
63
+ - ` reverse_dns `
64
+ - ` find_enrichment_table_records `
65
+ - ` get_enrichment_table_record `
65
66
66
67
Functions from VRL stdlib that are currently not supported can be found
67
68
with this [ issue filter] [ vrl-wasm-unsupported-filter ]
Original file line number Diff line number Diff line change @@ -100,13 +100,29 @@ export class VrlWebPlayground {
100
100
program : this . programEditor . getValue ( ) ,
101
101
event : this . eventEditor . getModel ( ) . getLinesContent ( ) . join ( "\n" ) ,
102
102
is_jsonl : true ,
103
+ error : null ,
103
104
} ;
104
105
}
105
- return {
106
- program : this . programEditor . getValue ( ) ,
107
- event : JSON . parse ( ( this . eventEditor . getValue ( ) . length == 0 ) ? "{}" : this . eventEditor . getValue ( ) ) ,
108
- is_jsonl : false ,
109
- } ;
106
+
107
+ const editorValue = this . eventEditor . getValue ( ) ;
108
+ try {
109
+ return {
110
+ program : this . programEditor . getValue ( ) ,
111
+ event : JSON . parse ( ( editorValue . length === 0 ) ? "{}" : editorValue ) ,
112
+ is_jsonl : false ,
113
+ error : null ,
114
+ } ;
115
+ }
116
+ catch ( error ) {
117
+ console . error ( error ) ;
118
+ return {
119
+ program : this . programEditor . getValue ( ) ,
120
+ event : null ,
121
+ is_jsonl : false ,
122
+ error : `Could not parse JSON event:\n${ editorValue } ` ,
123
+ } ;
124
+ }
125
+ return state ;
110
126
}
111
127
112
128
disableJsonLinting ( ) {
@@ -168,6 +184,11 @@ export class VrlWebPlayground {
168
184
if ( input == null ) {
169
185
input = this . getState ( ) ;
170
186
}
187
+ if ( input . error ) {
188
+ this . disableJsonLinting ( ) ;
189
+ this . outputEditor . setValue ( input . error ) ;
190
+ return input ;
191
+ }
171
192
172
193
let res = this . run_vrl ( input ) ;
173
194
console . log ( "[DEBUG::handleRunCode()] Printing out res: " , res ) ;
Original file line number Diff line number Diff line change 8
8
],
9
9
"module" : " vector_vrl_web_playground.js" ,
10
10
"types" : " vector_vrl_web_playground.d.ts" ,
11
- "sideEffects" : [
12
- " ./snippets/*"
13
- ]
11
+ "sideEffects" : false
14
12
}
You can’t perform that action at this time.
0 commit comments