[Enterprise Search] Fix Error Connecting view not displaying for auth issues (#105125)

* Fix ent-search authentication to show the error connecting screen

Missed this in #103555

* [Misc] updoot handleConnectionError order/spacing to match

- why? because i've lost control of my life, probably
This commit is contained in:
Constance 2021-07-09 14:31:01 -07:00 committed by GitHub
parent bcc8ee2532
commit 1739b55f94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -403,7 +403,7 @@ describe('EnterpriseSearchRequestHandler', () => {
expect(responseMock.customError).toHaveBeenCalledWith({
statusCode: 502,
body: 'Cannot authenticate Enterprise Search user',
headers: mockExpectedResponseHeaders,
headers: { ...mockExpectedResponseHeaders, [ERROR_CONNECTING_HEADER]: 'true' },
});
expect(mockLogger.error).toHaveBeenCalled();
});

View file

@ -283,12 +283,11 @@ export class EnterpriseSearchRequestHandler {
handleConnectionError(response: KibanaResponseFactory, e: Error) {
const errorMessage = `Error connecting to Enterprise Search: ${e?.message || e.toString()}`;
const headers = { ...this.headers, [ERROR_CONNECTING_HEADER]: 'true' };
this.log.error(errorMessage);
if (e instanceof Error) this.log.debug(e.stack as string);
const headers = { ...this.headers, [ERROR_CONNECTING_HEADER]: 'true' };
return response.customError({ statusCode: 502, headers, body: errorMessage });
}
@ -298,9 +297,10 @@ export class EnterpriseSearchRequestHandler {
*/
handleAuthenticationError(response: KibanaResponseFactory) {
const errorMessage = 'Cannot authenticate Enterprise Search user';
const headers = { ...this.headers, [ERROR_CONNECTING_HEADER]: 'true' };
this.log.error(errorMessage);
return response.customError({ statusCode: 502, headers: this.headers, body: errorMessage });
return response.customError({ statusCode: 502, headers, body: errorMessage });
}
/**