Skip to content

Commit 3c0721b

Browse files
committed
[Bug] Ensure only supported connectors appear in the Security Solution & Agent Builder AI connector selector (elastic#244533)
## Summary Summarize your PR. If it involves visual changes, include a screenshot or gif. Fix bug where unsupported connectors appeared in the security ai assistant and agent builder connector selector. How to test the fix: - Set up an AI connector (inference) - In Additional settings, make sure "text embeddings" is selected <img width="828" height="416" alt="image" src="https://github.com/user-attachments/assets/328d7f9c-4c4c-412c-95dd-7bcb8f37077e" /> (to set up a text embedding connector, I used a personal OpenAI key and picked one of the OpenAI embedding models) - Go to the security AI assistant and open the connector drop-down. - Ensure your text embeddings connector does not appear. - Check text embedding connector does not appear in the agent builder connector selector either Previously, the embedding connector would appear but be unusable. Example: Incompatible AI connector <img width="1734" height="1784" alt="image" src="https://github.com/user-attachments/assets/51fe0a2c-c6fe-455d-8caa-b7c437f7cc31" /> Compatible AI connector <img width="1796" height="1816" alt="image" src="https://github.com/user-attachments/assets/5ed5d7cd-b620-40ce-b46e-df5a0bf3d796" /> Security connector Selector should look like this: <img width="910" height="928" alt="image" src="https://github.com/user-attachments/assets/44dc00fb-c55f-4bf1-9e77-9f0cf2b8799e" /> Agent builder connector selector should look like this: <img width="728" height="379" alt="image" src="https://github.com/user-attachments/assets/00b15daa-1c73-44b8-b1fa-b7db3916d326" /> ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [X] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [X] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [X] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [X] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [X] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [X] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [X] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [X] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: kibanamachine <[email protected]> (cherry picked from commit d128d41) # Conflicts: # x-pack/platform/packages/shared/kbn-elastic-assistant/impl/mock/connectors.ts
1 parent 615dfe7 commit 3c0721b

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

x-pack/platform/packages/shared/kbn-elastic-assistant/impl/connectorland/use_load_connectors/index.test.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616

1717
const mockConnectorsAndExtras = [
1818
...mockConnectors,
19+
// These connectors are not supported for inference
1920
{
2021
...mockConnectors[0],
2122
id: 'connector-missing-secrets',
@@ -30,6 +31,16 @@ const mockConnectorsAndExtras = [
3031
isMissingSecrets: true,
3132
actionTypeId: '.d3',
3233
},
34+
{
35+
...mockConnectors[0],
36+
id: 'connector-text-embedding',
37+
name: 'Text Embedding Connector',
38+
isMissingSecrets: false,
39+
actionTypeId: '.inference',
40+
config: {
41+
taskType: 'text_embedding',
42+
},
43+
},
3344
];
3445

3546
const connectorsApiResponse = mockConnectorsAndExtras.map((c) => ({
@@ -122,4 +133,22 @@ describe('useLoadConnectors', () => {
122133
});
123134
await waitFor(() => expect(toasts.addError).toHaveBeenCalled());
124135
});
136+
137+
it('should filter out .inference connectors without chat_completion taskType', async () => {
138+
const { result } = renderHook(
139+
() => useLoadConnectors({ ...defaultProps, inferenceEnabled: true }),
140+
{
141+
wrapper: TestProviders,
142+
}
143+
);
144+
await waitFor(() => {
145+
const connectorIds = result.current.data?.map((c) => c.id) || [];
146+
147+
expect(connectorIds).not.toContain('connector-text-embedding');
148+
expect(connectorIds).not.toContain('text-embedding-connector-id');
149+
expect(connectorIds).not.toContain('sparse-embedding-connector-id');
150+
expect(connectorIds).toContain('c29c28a0-20fe-11ee-9386-a1f4d42ec542'); // Regular Inference Connector
151+
expect(connectorIds).toContain('connectorId'); // OpenAI connector
152+
});
153+
});
125154
});

x-pack/platform/packages/shared/kbn-elastic-assistant/impl/connectorland/use_load_connectors/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type { IHttpFetchError, HttpSetup } from '@kbn/core-http-browser';
1313
import type { IToasts } from '@kbn/core-notifications-browser';
1414
import type { OpenAiProviderType } from '@kbn/stack-connectors-plugin/common/openai/constants';
1515
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
16+
import { isSupportedConnector } from '@kbn/inference-common';
1617
import { getAvailableAiConnectors } from '@kbn/elastic-assistant-common/impl/connectors/get_available_connectors';
1718
import type { AIConnector } from '../connector_selector';
1819
import * as i18n from '../translations';
@@ -49,7 +50,11 @@ export const useLoadConnectors = ({
4950
const connectors = await loadConnectors({ http });
5051

5152
const allAiConnectors = connectors.flatMap((connector) => {
52-
if (!connector.isMissingSecrets && actionTypes.includes(connector.actionTypeId)) {
53+
if (
54+
!connector.isMissingSecrets &&
55+
actionTypes.includes(connector.actionTypeId) &&
56+
isSupportedConnector(connector)
57+
) {
5358
const aiConnector: AIConnector = {
5459
...connector,
5560
apiProvider:

x-pack/platform/packages/shared/kbn-elastic-assistant/impl/mock/connectors.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,7 @@ export const mockConnectors: AIConnector[] = [
8282
isSystemAction: false,
8383
config: {
8484
apiProvider: 'OpenAI',
85+
taskType: 'chat_completion',
8586
},
8687
},
87-
{
88-
id: 'c29c28a0-20fe-11ee-9396-a1f4d42ec542',
89-
name: 'Preconfigured Inference Connector',
90-
isMissingSecrets: false,
91-
actionTypeId: '.inference',
92-
isPreconfigured: true,
93-
isDeprecated: false,
94-
isSystemAction: false,
95-
},
9688
];

0 commit comments

Comments
 (0)