From 9fa30d67a0bfdb9809980a7c0a3756721ae9e7bf Mon Sep 17 00:00:00 2001 From: Isaac Hill <71404865+isaachilly@users.noreply.github.com> Date: Thu, 7 May 2026 19:00:25 +0200 Subject: [PATCH 1/3] [OGUI-1073] Redirect user to default filtered page if URL filter params are unparseable Added a try and catch to check if the URL filter params are parseable, if they are not raise a danger notification stating the JSON error message. --- InfoLogger/public/Model.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/InfoLogger/public/Model.js b/InfoLogger/public/Model.js index 7dcd8d802..308633a6a 100644 --- a/InfoLogger/public/Model.js +++ b/InfoLogger/public/Model.js @@ -333,7 +333,13 @@ export default class Model extends Observable { return; } else if (params.q) { this.getUserProfile(); - this.log.filter.fromObject(JSON.parse(params.q.replaceAll('\n', '\\n'))); + try { + this.log.filter.fromObject(JSON.parse(params.q.replaceAll('\n', '\\n'))); + } catch (error) { + this.log.filter.resetCriteria(); + this.updateRouteOnModelChange(); + this.notification.show(`Invalid URL filter format: ${error.message}`, 'danger'); + } } else { this.getUserProfile(); } From 22d5f7aba1ca3c099926cc58bde4b226b4c6f469 Mon Sep 17 00:00:00 2001 From: Isaac Hill <71404865+isaachilly@users.noreply.github.com> Date: Thu, 7 May 2026 19:01:22 +0200 Subject: [PATCH 2/3] [OGUI-1073] Added test case for invalid URL filters params notification --- .../test/public/log-filter-actions-mocha.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/InfoLogger/test/public/log-filter-actions-mocha.js b/InfoLogger/test/public/log-filter-actions-mocha.js index 4b67ebe56..86f20643a 100644 --- a/InfoLogger/test/public/log-filter-actions-mocha.js +++ b/InfoLogger/test/public/log-filter-actions-mocha.js @@ -93,6 +93,25 @@ describe('Filter actions test-suite', async () => { assert.strictEqual(searchParams, expectedParams); }); + it('should redirect to default filters and show JSON parse error on malformed q in URI', async () => { + const expectedDefaultParams = '?q={"severity":{"in":"I W E F"}}'; + + const locationAndNotification = await page.evaluate(() => { + const params = { q: '{"severity":{"in":"W I E F"' }; + window.model.parseLocation(params); + return { + search: window.location.search, + notification: window.model.notification, + }; + }); + + assert.strictEqual(decodeURI(locationAndNotification.search), expectedDefaultParams); + assert.strictEqual(locationAndNotification.notification.type, 'danger'); + assert.strictEqual( + locationAndNotification.notification.message, + 'Invalid URL filter format: JSON.parse: expected \'.\' or \'}\' after property value in object at line 1 column 28 of the JSON data'); + }); + it('should update URI with new encoded "match" criteria', async () => { /* eslint-disable max-len */ const decodedParams = '?q={"hostname":{"match":"\\"%ald_qdip01%"},"severity":{"in":"I W E F"}}'; From 8889d92dee4d9c0e3afc521900b4721c404fa0f0 Mon Sep 17 00:00:00 2001 From: Isaac Hill <71404865+isaachilly@users.noreply.github.com> Date: Thu, 7 May 2026 19:18:05 +0200 Subject: [PATCH 3/3] [OGUI-1073] Make error message match CI/CD browser Parsing error is engine-specific and CI/CD with Puppeteer uses Chromium by default. --- InfoLogger/test/public/log-filter-actions-mocha.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/InfoLogger/test/public/log-filter-actions-mocha.js b/InfoLogger/test/public/log-filter-actions-mocha.js index 86f20643a..1cba99c65 100644 --- a/InfoLogger/test/public/log-filter-actions-mocha.js +++ b/InfoLogger/test/public/log-filter-actions-mocha.js @@ -107,9 +107,10 @@ describe('Filter actions test-suite', async () => { assert.strictEqual(decodeURI(locationAndNotification.search), expectedDefaultParams); assert.strictEqual(locationAndNotification.notification.type, 'danger'); + // CI/CD runs on Chromium so this assertion is based on Chromium's JSON engine's error message assert.strictEqual( locationAndNotification.notification.message, - 'Invalid URL filter format: JSON.parse: expected \'.\' or \'}\' after property value in object at line 1 column 28 of the JSON data'); + 'Invalid URL filter format: Expected \',\' or \'}\' after property value in JSON at position 27 (line 1 column 28)'); }); it('should update URI with new encoded "match" criteria', async () => {