kibana/x-pack/packages
Kibana Machine 79d1c6029b
[8.17] [Bug] [Assistant API] - Do not allow empty conversation ID in chat/complete route (#11783) (#213049) (#213086)
# Backport

This will backport the following commits from `main` to `8.17`:
- [[Bug] [Assistant API] - Do not allow empty conversation ID in
chat/complete route (#11783)
(#213049)](https://github.com/elastic/kibana/pull/213049)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Ievgen
Sorokopud","email":"ievgen.sorokopud@elastic.co"},"sourceCommit":{"committedDate":"2025-03-04T12:05:51Z","message":"[Bug]
[Assistant API] - Do not allow empty conversation ID in chat/complete
route (#11783) (#213049)\n\n## Summary\n\nBUG:
https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes
the behaviour of the\n`/api/security_ai_assistant/chat/complete` route
where the\n`conversationId` can be passed as an empty string. This may
lead to\nunexpected results described
in\nhttps://github.com/elastic/security-team/issues/11783#issuecomment-2696529040.\n\n###
Expected behaviour\n\nWe should throw a bad request (400) http error
when empty\n`conversationId` has been passed.\n\n### Testing\n\n* Use
this `curl` command to test the endpoint.\n\n```\ncurl --location
'http://localhost:5601/api/security_ai_assistant/chat/complete'
\\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type:
application/json' \\\n--data '{\n \"connectorId\":
\"{{my-gpt4o-ai}}\",\n \"conversationId\": \"\",\n \"isStream\":
false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\":
\"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\nYou should see next
error as a response:\n\n```\n{\n \"statusCode\": 400,\n \"error\": \"Bad
Request\",\n \"message\": \"[request body]: conversationId: String must
contain at least 1 character(s), conversationId: No empty strings
allowed\"\n}\n```\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"7db897a5393f2d776eca1d9760801dc2fa72ad9d","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","Team:
SecuritySolution","Team:Security Generative
AI","backport:version","v8.17.0","v8.18.0","v9.1.0","v8.19.0"],"title":"[Bug]
[Assistant API] - Do not allow empty conversation ID in chat/complete
route
(#11783)","number":213049,"url":"https://github.com/elastic/kibana/pull/213049","mergeCommit":{"message":"[Bug]
[Assistant API] - Do not allow empty conversation ID in chat/complete
route (#11783) (#213049)\n\n## Summary\n\nBUG:
https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes
the behaviour of the\n`/api/security_ai_assistant/chat/complete` route
where the\n`conversationId` can be passed as an empty string. This may
lead to\nunexpected results described
in\nhttps://github.com/elastic/security-team/issues/11783#issuecomment-2696529040.\n\n###
Expected behaviour\n\nWe should throw a bad request (400) http error
when empty\n`conversationId` has been passed.\n\n### Testing\n\n* Use
this `curl` command to test the endpoint.\n\n```\ncurl --location
'http://localhost:5601/api/security_ai_assistant/chat/complete'
\\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type:
application/json' \\\n--data '{\n \"connectorId\":
\"{{my-gpt4o-ai}}\",\n \"conversationId\": \"\",\n \"isStream\":
false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\":
\"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\nYou should see next
error as a response:\n\n```\n{\n \"statusCode\": 400,\n \"error\": \"Bad
Request\",\n \"message\": \"[request body]: conversationId: String must
contain at least 1 character(s), conversationId: No empty strings
allowed\"\n}\n```\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"7db897a5393f2d776eca1d9760801dc2fa72ad9d"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.17","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/213049","number":213049,"mergeCommit":{"message":"[Bug]
[Assistant API] - Do not allow empty conversation ID in chat/complete
route (#11783) (#213049)\n\n## Summary\n\nBUG:
https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes
the behaviour of the\n`/api/security_ai_assistant/chat/complete` route
where the\n`conversationId` can be passed as an empty string. This may
lead to\nunexpected results described
in\nhttps://github.com/elastic/security-team/issues/11783#issuecomment-2696529040.\n\n###
Expected behaviour\n\nWe should throw a bad request (400) http error
when empty\n`conversationId` has been passed.\n\n### Testing\n\n* Use
this `curl` command to test the endpoint.\n\n```\ncurl --location
'http://localhost:5601/api/security_ai_assistant/chat/complete'
\\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type:
application/json' \\\n--data '{\n \"connectorId\":
\"{{my-gpt4o-ai}}\",\n \"conversationId\": \"\",\n \"isStream\":
false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\":
\"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\nYou should see next
error as a response:\n\n```\n{\n \"statusCode\": 400,\n \"error\": \"Bad
Request\",\n \"message\": \"[request body]: conversationId: String must
contain at least 1 character(s), conversationId: No empty strings
allowed\"\n}\n```\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"7db897a5393f2d776eca1d9760801dc2fa72ad9d"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Ievgen Sorokopud <ievgen.sorokopud@elastic.co>
2025-03-04 16:32:26 +01:00
..
ai-infra [8.17] [product documentation] Fix index names (#202265) (#202307) 2024-11-29 09:16:55 -06:00
index-lifecycle-management/index_lifecycle_management_common_shared [8.x] [ilm] Remove observability solution dependency on index lifecycle management plugin bundle (#199383) (#199986) 2024-11-14 10:52:12 +01:00
index-management/index_management_shared_types [8.x] [Dataset Quality] Add fix it flow for field limit (#195561) (#197817) 2024-10-25 11:10:42 -05:00
kbn-ai-assistant [8.17] [Obs AI Assistant] fix knowledge base installation state (#206130) (#206837) 2025-01-15 15:12:47 -05:00
kbn-ai-assistant-common [8.x] [AI Assistant] Set scope and rename to Observability and Search (#196322) (#197609) 2024-10-24 09:31:22 -05:00
kbn-alerting-comparators [OBS-UX-MNGMT] Move the Alerting comparators from TriggersActionsUI plugin to the alerting-types package (#181584) 2024-05-28 15:34:52 +02:00
kbn-alerting-state-types [Move @kbn/config-schema to server] @kbn/alerting-state-types (#191786) 2024-09-02 16:46:48 -05:00
kbn-cloud-security-posture [8.x] [Cloud Security] Alerts Datagrids for Contextual Flyout (#199573) (#200245) 2024-11-14 14:55:26 -06:00
kbn-data-forge [8.17] Fix Custom Threshold Rule &#x60;ViewInAppUrl&#x60; does not honor space (#201793) (#203735) 2024-12-11 06:16:07 -06:00
kbn-elastic-assistant [8.17] [Security Solution] [KB Management] Fix sorting by name in the kb entries table (#209141) (#210525) 2025-02-11 13:40:12 +01:00
kbn-elastic-assistant-common [8.17] [Bug] [Assistant API] - Do not allow empty conversation ID in chat/complete route (#11783) (#213049) (#213086) 2025-03-04 16:32:26 +01:00
kbn-entities-schema [8.x] [Inventory][ECO] Replace Entity with InventoryEntityLatest type (#198760) (#199967) 2024-11-13 06:06:37 -06:00
kbn-infra-forge [Dev] Add High Cardinality Indexer to Kibana as kbn-data-forge (#174559) 2024-01-23 16:32:09 -07:00
kbn-langchain [8.17] [Security solution] Fix gemini streaming (#201299) (#201373) 2024-11-22 08:44:00 -06:00
kbn-random-sampling [8.17] [Lens] add an accessible label to range slider (#205308) (#208307) 2025-01-25 23:57:07 +00:00
kbn-slo-schema [8.17] [SLOs] Added $state into filters schema !! (#202887) (#203056) 2024-12-05 05:12:25 -06:00
kbn-synthetics-private-location [Synthetics] add synthetics-private-location command (#189531) 2024-08-09 07:02:02 -04:00
maps/vector_tile_utils [maps] fix double encoding MVT request body (#157788) 2023-05-16 14:45:40 -06:00
ml [8.17] [ML] Trained Models: Add a tech preview lable for rerank model (#203587) (#203704) 2024-12-10 18:48:46 -06:00
observability [8.17] [ES &#x60;body&#x60; removal] &#x60;@elastic/observability-ui&#x60; (#204873) (#209224) 2025-02-02 20:34:00 +01:00
rollup [Rollups] Update Rollup badge for deprecation (#186321) 2024-06-21 19:42:25 +01:00
search/shared_ui [8.x] [Onboarding] UX Feedback - Slight Tweaks to search detail (#194873) (#196314) 2024-10-15 10:33:38 -05:00
security [8.17] [Spaces UI] Role Editor Flyout Should Match in Roles Mgmt (#198182) (#202821) 2024-12-04 19:51:52 -05:00
security-solution [8.17] [Security Assistant] Move security AI assistant button into global nav bar (#203060) (#205885) 2025-01-09 10:01:54 +01:00