diff --git a/CHANGELOG.md b/CHANGELOG.md index 4849bfcf13b2..a5193ee87c54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,7 +75,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - [Discover] Enable 'Back to Top' Feature in Discover for scrolling to top ([#6008](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6008)) - [Discover] Fix lazy loading of the legacy table from getting stuck ([#6041](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6041)) - [BUG][Discover] Allow saved sort from search embeddable to load in Dashboard ([#5934](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5934)) -- [osd/std] Add additional recovery from false-positives in handling of long numerals ([#5956](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5956)) +- [osd/std] Add additional recovery from false-positives in handling of long numerals ([#5956](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5956), [#6245](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6245)) - [BUG][Multiple Datasource] Fix missing customApiRegistryPromise param for test connection ([#5944](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5944)) - [BUG][Multiple Datasource] Add a migration function for datasource to add migrationVersion field ([#6025](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6025)) - [BUG][MD]Expose picker using function in data source management plugin setup([#6030](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6030)) diff --git a/packages/osd-std/src/json.ts b/packages/osd-std/src/json.ts index 3af3d3c4b96c..7387790169a3 100644 --- a/packages/osd-std/src/json.ts +++ b/packages/osd-std/src/json.ts @@ -152,7 +152,8 @@ const parseStringWithLongNumerals = ( /* There are two types of exception objects that can be raised: * 1) a textual message with the position that we need to parse * i. Unexpected [token|string ...] at position ... - * ii. expected ',' or '}' after property value in object at line ... column ... + * ii. Expected ',' or ... after ... in JSON at position ... + * iii. expected ',' or ... after ... in object at line ... column ... * 2) a proper object with lineNumber and columnNumber which we can use * Note: this might refer to the part of the code that threw the exception but * we will try it anyway; the regex is specific enough to not produce @@ -161,23 +162,24 @@ const parseStringWithLongNumerals = ( let { lineNumber, columnNumber } = e; if (typeof e?.message === 'string') { - /* Check for 1-i (seen in Node) + /* Check for 1-i and 1-ii * Finding "..."เทด1111"..." inside a string value, the extra quotes throw a syntax error * and the position points to " that is assumed to be the begining of a value. */ - let match = e.message.match(/^Unexpected .*at position (\d+)(\s|$)/); + let match = e.message.match(/^(?:Une|E)xpected .*at position (\d+)(\D|$)/i); if (match) { lineNumber = 1; // Add 1 to reach the marker columnNumber = parseInt(match[1], 10) + 1; } else { - /* Check for 1-ii (seen in browsers) + /* Check for 1-iii * Finding "...,"เทด1111"..." inside a string value, the extra quotes throw a syntax error * and the column number points to the marker after the " that is assumed to be terminating the * value. + * PS: There are different versions of this error across browsers and platforms. */ // ToDo: Add functional tests for this path - match = e.message.match(/expected .*at line (\d+) column (\d+)(\s|$)/); + match = e.message.match(/expected .*line (\d+) column (\d+)(\D|$)/i); if (match) { lineNumber = parseInt(match[1], 10); columnNumber = parseInt(match[2], 10);