From 7fae4a30be0293b29503e604d9a1a9a85ce6472a Mon Sep 17 00:00:00 2001 From: Mohamed Abdelgaber Date: Fri, 25 Oct 2024 17:44:44 +0200 Subject: [PATCH 1/7] Fix issue empty user-hash in data view request headers to fix not compliant http request --- .../data_views/public/data_views/data_views_api_client.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/data_views/public/data_views/data_views_api_client.ts b/src/plugins/data_views/public/data_views/data_views_api_client.ts index e569e7f25bff6..e9d6c21c4c586 100644 --- a/src/plugins/data_views/public/data_views/data_views_api_client.ts +++ b/src/plugins/data_views/public/data_views/data_views_api_client.ts @@ -56,7 +56,8 @@ export class DataViewsApiClient implements IDataViewsApiClient { const userId = await this.getCurrentUserId(); const userHash = userId ? await sha1(userId) : ''; - + const headers = userHash ? { 'user-hash': userHash } : {}; + const request = body ? this.http.post(url, { query, body, version, asResponse }) : this.http.fetch(url, { @@ -64,7 +65,7 @@ export class DataViewsApiClient implements IDataViewsApiClient { version, ...cacheOptions, asResponse, - headers: { 'user-hash': userHash }, + headers, }); return request.catch((resp) => { From 497628629cbc115fd987edeb8a69e6583b9e9570 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:01:19 +0000 Subject: [PATCH 2/7] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../data_views/public/data_views/data_views_api_client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data_views/public/data_views/data_views_api_client.ts b/src/plugins/data_views/public/data_views/data_views_api_client.ts index e9d6c21c4c586..6bb7bc903a250 100644 --- a/src/plugins/data_views/public/data_views/data_views_api_client.ts +++ b/src/plugins/data_views/public/data_views/data_views_api_client.ts @@ -57,7 +57,7 @@ export class DataViewsApiClient implements IDataViewsApiClient { const userHash = userId ? await sha1(userId) : ''; const headers = userHash ? { 'user-hash': userHash } : {}; - + const request = body ? this.http.post(url, { query, body, version, asResponse }) : this.http.fetch(url, { From 65696c16c5d83bead29ba7145a2ec70a92362b79 Mon Sep 17 00:00:00 2001 From: Mohamed Abdelgaber Date: Mon, 28 Oct 2024 15:09:00 +0100 Subject: [PATCH 3/7] [8.15] [test] [data view] temp disable checking 'user-hash' header Update data_views_api_client.test.ts --- .../public/data_views/data_views_api_client.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/data_views/public/data_views/data_views_api_client.test.ts b/src/plugins/data_views/public/data_views/data_views_api_client.test.ts index 8e1261802fbbc..6a84c69fe1e91 100644 --- a/src/plugins/data_views/public/data_views/data_views_api_client.test.ts +++ b/src/plugins/data_views/public/data_views/data_views_api_client.test.ts @@ -29,10 +29,11 @@ describe('IndexPatternsApiClient', () => { expect(fetchSpy).toHaveBeenCalledWith(expectedPath, { // not sure what asResponse is but the rest of the results are useful + // temp disable checking 'user-hash' header asResponse: true, - headers: { - 'user-hash': '', - }, + // headers: { + // 'user-hash': '', + // }, query: { allow_hidden: undefined, allow_no_index: undefined, From ac05669c09f541e26fcb2f44276bba7cc5e2665b Mon Sep 17 00:00:00 2001 From: Mohamed Abdelgaber Date: Mon, 28 Oct 2024 19:41:09 +0100 Subject: [PATCH 4/7] [8.15] [testing] [data view] disable checking 'user-hash' header --- .../public/data_views/data_views_api_client.test.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/plugins/data_views/public/data_views/data_views_api_client.test.ts b/src/plugins/data_views/public/data_views/data_views_api_client.test.ts index 6a84c69fe1e91..4eaf2e88f56d9 100644 --- a/src/plugins/data_views/public/data_views/data_views_api_client.test.ts +++ b/src/plugins/data_views/public/data_views/data_views_api_client.test.ts @@ -29,11 +29,7 @@ describe('IndexPatternsApiClient', () => { expect(fetchSpy).toHaveBeenCalledWith(expectedPath, { // not sure what asResponse is but the rest of the results are useful - // temp disable checking 'user-hash' header asResponse: true, - // headers: { - // 'user-hash': '', - // }, query: { allow_hidden: undefined, allow_no_index: undefined, From 1de89e3c4b48209be82b25f2872feb1616961a0f Mon Sep 17 00:00:00 2001 From: "mabdelgaber.SEC" Date: Mon, 28 Oct 2024 18:55:00 +0000 Subject: [PATCH 5/7] [8.15] [dataview] replace empty header obj with undefined --- .../data_views/public/data_views/data_views_api_client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data_views/public/data_views/data_views_api_client.ts b/src/plugins/data_views/public/data_views/data_views_api_client.ts index 6bb7bc903a250..233b05ea7bc22 100644 --- a/src/plugins/data_views/public/data_views/data_views_api_client.ts +++ b/src/plugins/data_views/public/data_views/data_views_api_client.ts @@ -56,7 +56,7 @@ export class DataViewsApiClient implements IDataViewsApiClient { const userId = await this.getCurrentUserId(); const userHash = userId ? await sha1(userId) : ''; - const headers = userHash ? { 'user-hash': userHash } : {}; + const headers = userHash ? { 'user-hash': userHash } : undefined; const request = body ? this.http.post(url, { query, body, version, asResponse }) From 664f34ab6d1b25ae406dc129febed1ada7612bb1 Mon Sep 17 00:00:00 2001 From: muhamed-abdelgaber Date: Mon, 28 Oct 2024 19:22:27 +0000 Subject: [PATCH 6/7] Revert "[8.15] [dataview] replace empty header obj with undefined" This reverts commit 1de89e3c4b48209be82b25f2872feb1616961a0f. --- .../data_views/public/data_views/data_views_api_client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data_views/public/data_views/data_views_api_client.ts b/src/plugins/data_views/public/data_views/data_views_api_client.ts index 233b05ea7bc22..6bb7bc903a250 100644 --- a/src/plugins/data_views/public/data_views/data_views_api_client.ts +++ b/src/plugins/data_views/public/data_views/data_views_api_client.ts @@ -56,7 +56,7 @@ export class DataViewsApiClient implements IDataViewsApiClient { const userId = await this.getCurrentUserId(); const userHash = userId ? await sha1(userId) : ''; - const headers = userHash ? { 'user-hash': userHash } : undefined; + const headers = userHash ? { 'user-hash': userHash } : {}; const request = body ? this.http.post(url, { query, body, version, asResponse }) From 85e8b52c603b34c89731d0b833716a2fa9e9b1ea Mon Sep 17 00:00:00 2001 From: Mohamed Abdelgaber Date: Mon, 28 Oct 2024 20:24:21 +0100 Subject: [PATCH 7/7] [8.15] [dataview] replace empty header obj with undefined --- .../data_views/public/data_views/data_views_api_client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data_views/public/data_views/data_views_api_client.ts b/src/plugins/data_views/public/data_views/data_views_api_client.ts index 6bb7bc903a250..233b05ea7bc22 100644 --- a/src/plugins/data_views/public/data_views/data_views_api_client.ts +++ b/src/plugins/data_views/public/data_views/data_views_api_client.ts @@ -56,7 +56,7 @@ export class DataViewsApiClient implements IDataViewsApiClient { const userId = await this.getCurrentUserId(); const userHash = userId ? await sha1(userId) : ''; - const headers = userHash ? { 'user-hash': userHash } : {}; + const headers = userHash ? { 'user-hash': userHash } : undefined; const request = body ? this.http.post(url, { query, body, version, asResponse })