diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.test.ts index 3e8322145dad6..1d1b47d154eaa 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.test.ts @@ -393,8 +393,10 @@ describe('SchemaLogic', () => { it('handles error with message', async () => { const onSchemaSetFormErrorsSpy = jest.spyOn(SchemaLogic.actions, 'onSchemaSetFormErrors'); - // We expect body.message to be a string[] when it is present - http.post.mockReturnValue(Promise.reject({ body: { message: ['this is an error'] } })); + // We expect body.attributes.errors to be a string[] when it is present + http.post.mockReturnValue( + Promise.reject({ body: { attributes: { errors: ['this is an error'] } } }) + ); SchemaLogic.actions.setServerField(schema, ADD); await nextTick(); diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.ts index 7af074d412a60..92420cef919cb 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.ts @@ -350,8 +350,8 @@ export const SchemaLogic = kea>({ } catch (e) { window.scrollTo(0, 0); if (isAdding) { - // We expect body.message to be a string[] for actions.onSchemaSetFormErrors - const message: string[] = e?.body?.message || [defaultErrorMessage]; + // We expect body.attributes.errors to be a string[] for actions.onSchemaSetFormErrors + const message: string[] = e?.body?.attributes?.errors || [defaultErrorMessage]; actions.onSchemaSetFormErrors(message); } else { flashAPIErrors(e);