File tree Expand file tree Collapse file tree 1 file changed +11
-20
lines changed
azure/activity_logs_monitoring Expand file tree Collapse file tree 1 file changed +11
-20
lines changed Original file line number Diff line number Diff line change @@ -390,27 +390,18 @@ class EventhubLogHandler {
390390 }
391391
392392 fixPropertiesJsonString ( record ) {
393- try {
394- // Check if properties field is a string
395- if ( typeof record . properties === 'string' ) {
396- // If it is a string, check if it is a malformed JSON String
397- // By checking for ':'
398- if ( record . properties . includes ( "':'" ) ) {
399- // If the check is true, find / replace single quotes
400- // with double quotes, to make a proper JSON
401- // which is then converted into a JSON Object
402- record . properties = JSON . parse ( record . properties . replace ( / ' / g, '"' ) ) ;
403- return record ;
404- } else {
405- return record ;
406- }
407- } else {
408- return record ;
393+ // Check if properties field is a malformed JSON String
394+ if ( Object . hasOwn ( record , 'properties' ) && ( typeof record . properties === 'string' ) && ( record . properties . includes ( "':'" ) ) ) {
395+ try {
396+ // If the check is true, find and replace single quotes
397+ // with double quotes, to make a proper JSON
398+ // which is then converted into a JSON Object
399+ parsedProperties = JSON . parse ( record . properties . replace ( / ' / g, '"' ) ) ;
400+ record . properties = parsedProperties ;
401+ } catch {
402+ this . context . error ( 'Unable to fix properties field to JSON Object' ) ;
409403 }
410- } catch {
411- this . context . error ( 'Unable to fix properties field to JSON Object' ) ;
412- return record ;
413- }
404+ return record ;
414405 }
415406
416407 handleLogs ( logs ) {
You can’t perform that action at this time.
0 commit comments