Skip to content

Commit 8296c4c

Browse files
authored
[AI Infra] Include error message when connector is not found (elastic#226910)
## Summary Improves error logging when fetching connector to include the actual error message to better debug the ongoing issue outlined in elastic#225711
1 parent b20ba3e commit 8296c4c

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

x-pack/platform/plugins/shared/inference/server/util/get_connector_by_id.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ describe('getConnectorById', () => {
5151
throw new Error('Something wrong');
5252
});
5353

54-
await expect(() =>
55-
getConnectorById({ actionsClient, connectorId })
56-
).rejects.toThrowErrorMatchingInlineSnapshot(`"No connector found for id 'my-connector-id'"`);
54+
await expect(() => getConnectorById({ actionsClient, connectorId })).rejects
55+
.toThrowErrorMatchingInlineSnapshot(`
56+
"No connector found for id 'my-connector-id'
57+
Something wrong"
58+
`);
5759
});
5860

5961
it('throws the connector type is not compatible', async () => {

x-pack/platform/plugins/shared/inference/server/util/get_connector_by_id.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export const getConnectorById = async ({
2929
throwIfSystemAction: true,
3030
});
3131
} catch (error) {
32-
throw createInferenceRequestError(`No connector found for id '${connectorId}'`, 400);
32+
throw createInferenceRequestError(
33+
`No connector found for id '${connectorId}'\n${error.message}`,
34+
400
35+
);
3336
}
3437

3538
return connectorToInference(connector);

x-pack/test/functional_gen_ai/inference/tests/chat_complete.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ export const chatCompleteSuite = (
168168
expect(message).to.eql({
169169
type: 'error',
170170
code: 'requestError',
171-
message: "No connector found for id 'do-not-exist'",
171+
message:
172+
"No connector found for id 'do-not-exist'\nSaved object [action/do-not-exist] not found",
172173
});
173174
});
174175

@@ -335,7 +336,8 @@ export const chatCompleteSuite = (
335336
type: 'error',
336337
error: {
337338
code: 'requestError',
338-
message: "No connector found for id 'do-not-exist'",
339+
message:
340+
"No connector found for id 'do-not-exist'\nSaved object [action/do-not-exist] not found",
339341
meta: {
340342
status: 400,
341343
},

0 commit comments

Comments
 (0)