kibana/oas_docs
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
..
examples [8.x] [DOCS] Remove inference connector docs (#198633) (#199846) 2024-11-12 13:56:59 -06:00
linters [8.x] [OpenAPI] Add redocly lint configuration (#199360) (#199554) 2024-11-08 17:22:00 -05:00
output [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
overlays [8.17] [OpenAPI] Fix Serverless API base URL (#202373) (#202584) 2024-12-03 10:51:05 -05:00
scripts [8.x][OpenAPI] Remove staging and serverless files and commands (#198623) 2024-11-01 10:46:38 +01:00
bundle.json [8.x] [OpenAPI][DOCS] Add descriptions for alerting rule flapping properties (#200112) (#200215) 2024-11-14 12:39:12 -06:00
kibana.info.yaml [DOCS][OpenAPI] Fix branch detail in introduction (#204099) 2024-12-12 13:40:10 -06:00
makefile [8.x] [OAS] Publish OAS bundles to bump.sh (#197482) (#200135) 2024-11-20 10:16:01 +01:00
package-lock.json [8.x] [OAS] Publish OAS bundles to bump.sh (#197482) (#200135) 2024-11-20 10:16:01 +01:00
package.json [8.x] [OAS] Publish OAS bundles to bump.sh (#197482) (#200135) 2024-11-20 10:16:01 +01:00
README.md [8.x] [OAS] Publish OAS bundles to bump.sh (#197482) (#200135) 2024-11-20 10:16:01 +01:00

Kibana API reference documentation

Documentation about our OpenAPI bundling workflow and configuration. See Kibana's hosted stateful and serverless docs.

Workflow

The final goal of this workflow is to produce an OpenAPI bundle containing all Kibana's public APIs.

Step 0

OAS from Kibana's APIs are continuously extracted and captured in bundle.json and bundle.serverless.json as fully formed OAS documentation. See node scripts/capture_oas_snapshot --help for more info.

These bundles form the basis of our OpenAPI bundles to which we append and layer extra information before publishing.

Step 1

Append pre-existing bundles not extracted from code using kbn-openapi-bundler to produce the final resulting bundles.

To add more files into the final bundle, edit the appropriate oas_docs/scripts/merge*.js files.

Step 2

Apply any final overalys to the document that might include examples or final tweaks (see the "Scripts" section for more details).

Scripts

The oas_docs/scripts folder contains scripts that point to the source domain-specific OpenAPI bundles and specify additional parameters for producing the final output bundle. Currently, there are the following scripts:

  • merge_ess_oas.js script produces production an output bundle for ESS

  • merge_serverless_oas.js script produces production an output bundle for Serverless

Output Kibana OpenAPI bundles

The oas_docs/output folder contains the final resulting Kibana OpenAPI bundles

  • kibana.yaml production ready ESS OpenAPI bundle
  • kibana.serverless.yaml production ready Serverless OpenAPI bundle

Bundling commands

Besides the scripts in the oas_docs/scripts folder, there is an oas_docs/makefile to simplify the workflow. Use make help to see available commands.