elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.69k stars 8.12k forks source link

[Obs AI Assistant] Knowledge base entries with the same name overwrites each other without warning #184069

Open sorenlouv opened 3 months ago

sorenlouv commented 3 months ago

When creating a new knowledge base article, the user can specify a "name". In the UI it looks like it is simply a human readable label but it is used as a unique identifier.

Problem

The problem is that it is not possible to have two KB entries with the same name. If a new entry is created with same name as an existing entry it will overwrite the other one without warning the user. This is especially problematic in systems with many KB articles and many different users producing them where it will happen more frequently and without them noticing.

To make matters worse, this also happens when the assistant persists knowledge from a conversation. If it picks a name for the KB entry that already exists, this will be overwritten.

Solution

We should auto-generate a uuid and use the that as the doc_id. The "name" should simply be a label and not be required to be unique.

image

image

miltonhultgren commented 3 months ago

The UUID ID solution makes it slightly harder for users to manage their entries and user instructions but perhaps that's okay. I outlined another possible solution in https://github.com/elastic/kibana/issues/183897 which allows users to keep using their "meaningful" IDs.

Also, in this PR I was changing from using index to use create instead which should throw if this situation happens (which at least makes the issue visible but doesn't address the access control issue) but that wasn't merged.

miltonhultgren commented 3 months ago

https://github.com/elastic/kibana/pull/183923 includes some code changes to make the access controls stricter but wasn't merged.