-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Obs AI Assistant] Fetch user instructions using id instead of username for knowledge base instructions #192701
Comments
Tests for serverless - copies over and modifies all tests from stateful to work in serverless. ~~deployment agnostic tests do not yet support enterprise license for stateful, so are tests don't yet qualify as being deployment agnostic~~. Given how difficult it is to see differences from the stateful tests, I've added PR comments where I've changed something that might be of interest. - changes to `createObservabilityAIAssistantApiClient` to use supertest without basic auth and accept headers for serverless and use roles - removes creating persisted users when tests start and [use roles](https://github.com/elastic/kibana/blob/main/x-pack/test_serverless/README.md#roles-based-testing) within tests. its not possible to create custom users with the serverless test framework at the moment. See #192711 Skipped tests - knowledge base tests #192886 - any test suite that uses the LLM proxy has been skipped on MKI #192751 - all tests that depend on the config.modelId skipped in MKI #192757 TODO: - [x] move over remaining tests - [x] test in MKI environment before merging - [x] create issues for skipped tests - [ ] this will not run on MKI (after merging) unless we ping the appex-qa team to add it to the pipeline. this is due to creating a separate config. ask appex-qa team to add our config. Followup / related issues to be tracked in a newly created issue: - [ ] #192757 - [ ] #192886 - [ ] #192751 - [ ] #192701 - [ ] #192497 - [ ] #192711 - [ ] #192718 - [ ] serverless functional tests - [ ] inquire with ml-ui-team to have the ability to delete system indices which we do after uninstalling tiny elser with .ml indices
Tests for serverless - copies over and modifies all tests from stateful to work in serverless. ~~deployment agnostic tests do not yet support enterprise license for stateful, so are tests don't yet qualify as being deployment agnostic~~. Given how difficult it is to see differences from the stateful tests, I've added PR comments where I've changed something that might be of interest. - changes to `createObservabilityAIAssistantApiClient` to use supertest without basic auth and accept headers for serverless and use roles - removes creating persisted users when tests start and [use roles](https://github.com/elastic/kibana/blob/main/x-pack/test_serverless/README.md#roles-based-testing) within tests. its not possible to create custom users with the serverless test framework at the moment. See elastic#192711 Skipped tests - knowledge base tests elastic#192886 - any test suite that uses the LLM proxy has been skipped on MKI elastic#192751 - all tests that depend on the config.modelId skipped in MKI elastic#192757 TODO: - [x] move over remaining tests - [x] test in MKI environment before merging - [x] create issues for skipped tests - [ ] this will not run on MKI (after merging) unless we ping the appex-qa team to add it to the pipeline. this is due to creating a separate config. ask appex-qa team to add our config. Followup / related issues to be tracked in a newly created issue: - [ ] elastic#192757 - [ ] elastic#192886 - [ ] elastic#192751 - [ ] elastic#192701 - [ ] elastic#192497 - [ ] elastic#192711 - [ ] elastic#192718 - [ ] serverless functional tests - [ ] inquire with ml-ui-team to have the ability to delete system indices which we do after uninstalling tiny elser with .ml indices
Tests for serverless - copies over and modifies all tests from stateful to work in serverless. ~~deployment agnostic tests do not yet support enterprise license for stateful, so are tests don't yet qualify as being deployment agnostic~~. Given how difficult it is to see differences from the stateful tests, I've added PR comments where I've changed something that might be of interest. - changes to `createObservabilityAIAssistantApiClient` to use supertest without basic auth and accept headers for serverless and use roles - removes creating persisted users when tests start and [use roles](https://github.com/elastic/kibana/blob/main/x-pack/test_serverless/README.md#roles-based-testing) within tests. its not possible to create custom users with the serverless test framework at the moment. See elastic#192711 Skipped tests - knowledge base tests elastic#192886 - any test suite that uses the LLM proxy has been skipped on MKI elastic#192751 - all tests that depend on the config.modelId skipped in MKI elastic#192757 TODO: - [x] move over remaining tests - [x] test in MKI environment before merging - [x] create issues for skipped tests - [ ] this will not run on MKI (after merging) unless we ping the appex-qa team to add it to the pipeline. this is due to creating a separate config. ask appex-qa team to add our config. Followup / related issues to be tracked in a newly created issue: - [ ] elastic#192757 - [ ] elastic#192886 - [ ] elastic#192751 - [ ] elastic#192701 - [ ] elastic#192497 - [ ] elastic#192711 - [ ] elastic#192718 - [ ] serverless functional tests - [ ] inquire with ml-ui-team to have the ability to delete system indices which we do after uninstalling tiny elser with .ml indices
Tests for serverless - copies over and modifies all tests from stateful to work in serverless. ~~deployment agnostic tests do not yet support enterprise license for stateful, so are tests don't yet qualify as being deployment agnostic~~. Given how difficult it is to see differences from the stateful tests, I've added PR comments where I've changed something that might be of interest. - changes to `createObservabilityAIAssistantApiClient` to use supertest without basic auth and accept headers for serverless and use roles - removes creating persisted users when tests start and [use roles](https://github.com/elastic/kibana/blob/main/x-pack/test_serverless/README.md#roles-based-testing) within tests. its not possible to create custom users with the serverless test framework at the moment. See elastic#192711 Skipped tests - knowledge base tests elastic#192886 - any test suite that uses the LLM proxy has been skipped on MKI elastic#192751 - all tests that depend on the config.modelId skipped in MKI elastic#192757 TODO: - [x] move over remaining tests - [x] test in MKI environment before merging - [x] create issues for skipped tests - [ ] this will not run on MKI (after merging) unless we ping the appex-qa team to add it to the pipeline. this is due to creating a separate config. ask appex-qa team to add our config. Followup / related issues to be tracked in a newly created issue: - [ ] elastic#192757 - [ ] elastic#192886 - [ ] elastic#192751 - [ ] elastic#192701 - [ ] elastic#192497 - [ ] elastic#192711 - [ ] elastic#192718 - [ ] serverless functional tests - [ ] inquire with ml-ui-team to have the ability to delete system indices which we do after uninstalling tiny elser with .ml indices
…194582) Tests for serverless - copies over and modifies all tests from stateful to work in serverless. ~~deployment agnostic tests do not yet support enterprise license for stateful, so are tests don't yet qualify as being deployment agnostic~~. Given how difficult it is to see differences from the stateful tests, I've added PR comments where I've changed something that might be of interest. - changes to `createObservabilityAIAssistantApiClient` to use supertest without basic auth and accept headers for serverless and use roles - removes creating persisted users when tests start and [use roles](https://github.com/elastic/kibana/blob/main/x-pack/test_serverless/README.md#roles-based-testing) within tests. its not possible to create custom users with the serverless test framework at the moment. See #192711 Skipped tests - knowledge base tests #192886 - any test suite that uses the LLM proxy has been skipped on MKI #192751 - all tests that depend on the config.modelId skipped in MKI #192757 TODO: - [x] move over remaining tests - [x] test in MKI environment before merging - [x] create issues for skipped tests - [ ] this will not run on MKI (after merging) unless we ping the appex-qa team to add it to the pipeline. this is due to creating a separate config. ask appex-qa team to add our config. Followup / related issues to be tracked in a newly created issue: - [ ] #192757 - [ ] #192886 - [ ] #192751 - [ ] #192701 - [ ] #192497 - [ ] #192711 - [ ] #192718 - [ ] serverless functional tests - [ ] inquire with ml-ui-team to have the ability to delete system indices which we do after uninstalling tiny elser with .ml indices ## Summary Summarize your PR. If it involves visual changes include a screenshot or gif. ### Checklist Delete any items that are not applicable to this PR. - [ ] 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/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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 - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] 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) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### Risk Matrix Delete this section if it is not applicable to this PR. Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release. When forming the risk matrix, consider some of the following examples and how they may potentially impact the change: | Risk | Probability | Severity | Mitigation/Notes | |---------------------------|-------------|----------|-------------------------| | Multiple Spaces—unexpected behavior in non-default Kibana Space. | Low | High | Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces. | | Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. | High | Low | Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure. | | Code should gracefully handle cases when feature X or plugin Y are disabled. | Medium | High | Unit tests will verify that any feature flag or plugin combination still results in our service operational. | | [See more potential risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) | ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
@neptunian, If this issue relates to the code: Lines 361 to 364 in 3d3b32f
could you clarify if the changes are needed in here: Lines 7 to 25 in 4a16e91
Also, could you provide guidance on testing the solution? Any specific test cases or setup recommendations would be very helpful. |
Note: Check why the id is optional to make sure it exists. Id is provided by security as optional. Why? |
## Summary [Obs AI Assistant] Fetch user instructions using id instead of username for knowledge base instructions #192701 To avoid potential collisions when fetching data, we should query for the user id instead of the user name when getting instructions.
## Summary [Obs AI Assistant] Fetch user instructions using id instead of username for knowledge base instructions elastic#192701 To avoid potential collisions when fetching data, we should query for the user id instead of the user name when getting instructions. (cherry picked from commit 518dc25)
#200759) # Backport This will backport the following commits from `main` to `8.x`: - [Obs AI Assistant Fetch user instructions using user_id (#200137)](#200137) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Arturo Lidueña","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-19T15:16:32Z","message":"Obs AI Assistant Fetch user instructions using user_id (#200137)\n\n## Summary\r\n\r\n[Obs AI Assistant] Fetch user instructions using id instead of username\r\nfor knowledge base instructions #192701\r\n\r\nTo avoid potential collisions when fetching data, we should query for\r\nthe user id instead of the user name when getting instructions.","sha":"518dc2591f845b9e0772d367f71065cd787ad9bf","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","backport:prev-minor","Team:Obs AI Assistant","ci:project-deploy-observability"],"title":"Obs AI Assistant Fetch user instructions using user_id ","number":200137,"url":"https://github.com/elastic/kibana/pull/200137","mergeCommit":{"message":"Obs AI Assistant Fetch user instructions using user_id (#200137)\n\n## Summary\r\n\r\n[Obs AI Assistant] Fetch user instructions using id instead of username\r\nfor knowledge base instructions #192701\r\n\r\nTo avoid potential collisions when fetching data, we should query for\r\nthe user id instead of the user name when getting instructions.","sha":"518dc2591f845b9e0772d367f71065cd787ad9bf"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200137","number":200137,"mergeCommit":{"message":"Obs AI Assistant Fetch user instructions using user_id (#200137)\n\n## Summary\r\n\r\n[Obs AI Assistant] Fetch user instructions using id instead of username\r\nfor knowledge base instructions #192701\r\n\r\nTo avoid potential collisions when fetching data, we should query for\r\nthe user id instead of the user name when getting instructions.","sha":"518dc2591f845b9e0772d367f71065cd787ad9bf"}}]}] BACKPORT--> Co-authored-by: Arturo Lidueña <[email protected]>
## Summary [Obs AI Assistant] Fetch user instructions using id instead of username for knowledge base instructions elastic#192701 To avoid potential collisions when fetching data, we should query for the user id instead of the user name when getting instructions.
…2833) [Obs AI Assistant] Fetch user instructions and conversation using user id instead of user name - #192701 To avoid potential collisions when fetching data, we should query for the user id instead of the user name when getting instructions or conversations. **If user.id is provided:** - Matches documents with user.id equal to the provided value. - Falls back to user.name when user.id does not exist in the document. **If user.id is not provided:** - Matches only documents with user.name. ## Summary Summarize your PR. If it involves visual changes include a screenshot or gif. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] 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/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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 - [ ] 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) - [ ] 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. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] 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)
…stic#202833) [Obs AI Assistant] Fetch user instructions and conversation using user id instead of user name - elastic#192701 To avoid potential collisions when fetching data, we should query for the user id instead of the user name when getting instructions or conversations. **If user.id is provided:** - Matches documents with user.id equal to the provided value. - Falls back to user.name when user.id does not exist in the document. **If user.id is not provided:** - Matches only documents with user.name. ## Summary Summarize your PR. If it involves visual changes include a screenshot or gif. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] 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/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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 - [ ] 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) - [ ] 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. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] 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) (cherry picked from commit 720ddd7)
…stic#202833) [Obs AI Assistant] Fetch user instructions and conversation using user id instead of user name - elastic#192701 To avoid potential collisions when fetching data, we should query for the user id instead of the user name when getting instructions or conversations. **If user.id is provided:** - Matches documents with user.id equal to the provided value. - Falls back to user.name when user.id does not exist in the document. **If user.id is not provided:** - Matches only documents with user.name. ## Summary Summarize your PR. If it involves visual changes include a screenshot or gif. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] 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/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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 - [ ] 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) - [ ] 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. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] 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) (cherry picked from commit 720ddd7)
…stic#202833) [Obs AI Assistant] Fetch user instructions and conversation using user id instead of user name - elastic#192701 To avoid potential collisions when fetching data, we should query for the user id instead of the user name when getting instructions or conversations. **If user.id is provided:** - Matches documents with user.id equal to the provided value. - Falls back to user.name when user.id does not exist in the document. **If user.id is not provided:** - Matches only documents with user.name. ## Summary Summarize your PR. If it involves visual changes include a screenshot or gif. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] 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/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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 - [ ] 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) - [ ] 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. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] 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)
…stic#202833) [Obs AI Assistant] Fetch user instructions and conversation using user id instead of user name - elastic#192701 To avoid potential collisions when fetching data, we should query for the user id instead of the user name when getting instructions or conversations. **If user.id is provided:** - Matches documents with user.id equal to the provided value. - Falls back to user.name when user.id does not exist in the document. **If user.id is not provided:** - Matches only documents with user.name. ## Summary Summarize your PR. If it involves visual changes include a screenshot or gif. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] 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/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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 - [ ] 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) - [ ] 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. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] 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)
#202833) (#202930) # Backport This will backport the following commits from `main` to `8.x`: - [Enhance access query logic to handle user ID and name conditions (#202833)](#202833) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Arturo Lidueña","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-04T13:56:28Z","message":"Enhance access query logic to handle user ID and name conditions (#202833)\n\n[Obs AI Assistant] Fetch user instructions and conversation using user\r\nid instead of user name -\r\nhttps://github.com//issues/192701\r\n\r\nTo avoid potential collisions when fetching data, we should query for\r\nthe user id instead of the user name when getting instructions or\r\nconversations.\r\n\r\n**If user.id is provided:**\r\n - Matches documents with user.id equal to the provided value.\r\n - Falls back to user.name when user.id does not exist in the document.\r\n \r\n**If user.id is not provided:**\r\n - Matches only documents with user.name.\r\n\r\n## Summary\r\n\r\nSummarize your PR. If it involves visual changes include a screenshot or\r\ngif.\r\n\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following conditions. \r\n\r\nReviewers should verify this PR satisfies this list as well.\r\n\r\n- [ ] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [ ] This was checked for breaking HTTP API changes, and any breaking\r\nchanges have been approved by the breaking-change committee. The\r\n`release_note:breaking` label should be applied in these situations.\r\n- [ ] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n- [ ] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"720ddd716bda9210ca92d21b0ed7065554118859","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","backport:prev-minor","backport:prev-major","Team:Obs AI Assistant","ci:project-deploy-observability"],"title":"Enhance access query logic to handle user ID and name conditions","number":202833,"url":"https://github.com/elastic/kibana/pull/202833","mergeCommit":{"message":"Enhance access query logic to handle user ID and name conditions (#202833)\n\n[Obs AI Assistant] Fetch user instructions and conversation using user\r\nid instead of user name -\r\nhttps://github.com//issues/192701\r\n\r\nTo avoid potential collisions when fetching data, we should query for\r\nthe user id instead of the user name when getting instructions or\r\nconversations.\r\n\r\n**If user.id is provided:**\r\n - Matches documents with user.id equal to the provided value.\r\n - Falls back to user.name when user.id does not exist in the document.\r\n \r\n**If user.id is not provided:**\r\n - Matches only documents with user.name.\r\n\r\n## Summary\r\n\r\nSummarize your PR. If it involves visual changes include a screenshot or\r\ngif.\r\n\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following conditions. \r\n\r\nReviewers should verify this PR satisfies this list as well.\r\n\r\n- [ ] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [ ] This was checked for breaking HTTP API changes, and any breaking\r\nchanges have been approved by the breaking-change committee. The\r\n`release_note:breaking` label should be applied in these situations.\r\n- [ ] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n- [ ] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"720ddd716bda9210ca92d21b0ed7065554118859"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202833","number":202833,"mergeCommit":{"message":"Enhance access query logic to handle user ID and name conditions (#202833)\n\n[Obs AI Assistant] Fetch user instructions and conversation using user\r\nid instead of user name -\r\nhttps://github.com//issues/192701\r\n\r\nTo avoid potential collisions when fetching data, we should query for\r\nthe user id instead of the user name when getting instructions or\r\nconversations.\r\n\r\n**If user.id is provided:**\r\n - Matches documents with user.id equal to the provided value.\r\n - Falls back to user.name when user.id does not exist in the document.\r\n \r\n**If user.id is not provided:**\r\n - Matches only documents with user.name.\r\n\r\n## Summary\r\n\r\nSummarize your PR. If it involves visual changes include a screenshot or\r\ngif.\r\n\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following conditions. \r\n\r\nReviewers should verify this PR satisfies this list as well.\r\n\r\n- [ ] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [ ] This was checked for breaking HTTP API changes, and any breaking\r\nchanges have been approved by the breaking-change committee. The\r\n`release_note:breaking` label should be applied in these situations.\r\n- [ ] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n- [ ] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"720ddd716bda9210ca92d21b0ed7065554118859"}}]}] BACKPORT--> Co-authored-by: Arturo Lidueña <[email protected]> Co-authored-by: Søren Louv-Jansen <[email protected]>
…ns (#202833) (#202929) # Backport This will backport the following commits from `main` to `8.17`: - [Enhance access query logic to handle user ID and name conditions (#202833)](#202833) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Arturo Lidueña","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-04T13:56:28Z","message":"Enhance access query logic to handle user ID and name conditions (#202833)\n\n[Obs AI Assistant] Fetch user instructions and conversation using user\r\nid instead of user name -\r\nhttps://github.com//issues/192701\r\n\r\nTo avoid potential collisions when fetching data, we should query for\r\nthe user id instead of the user name when getting instructions or\r\nconversations.\r\n\r\n**If user.id is provided:**\r\n - Matches documents with user.id equal to the provided value.\r\n - Falls back to user.name when user.id does not exist in the document.\r\n \r\n**If user.id is not provided:**\r\n - Matches only documents with user.name.\r\n\r\n## Summary\r\n\r\nSummarize your PR. If it involves visual changes include a screenshot or\r\ngif.\r\n\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following conditions. \r\n\r\nReviewers should verify this PR satisfies this list as well.\r\n\r\n- [ ] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [ ] This was checked for breaking HTTP API changes, and any breaking\r\nchanges have been approved by the breaking-change committee. The\r\n`release_note:breaking` label should be applied in these situations.\r\n- [ ] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n- [ ] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"720ddd716bda9210ca92d21b0ed7065554118859","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","backport:prev-minor","backport:prev-major","Team:Obs AI Assistant","ci:project-deploy-observability"],"title":"Enhance access query logic to handle user ID and name conditions","number":202833,"url":"https://github.com/elastic/kibana/pull/202833","mergeCommit":{"message":"Enhance access query logic to handle user ID and name conditions (#202833)\n\n[Obs AI Assistant] Fetch user instructions and conversation using user\r\nid instead of user name -\r\nhttps://github.com//issues/192701\r\n\r\nTo avoid potential collisions when fetching data, we should query for\r\nthe user id instead of the user name when getting instructions or\r\nconversations.\r\n\r\n**If user.id is provided:**\r\n - Matches documents with user.id equal to the provided value.\r\n - Falls back to user.name when user.id does not exist in the document.\r\n \r\n**If user.id is not provided:**\r\n - Matches only documents with user.name.\r\n\r\n## Summary\r\n\r\nSummarize your PR. If it involves visual changes include a screenshot or\r\ngif.\r\n\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following conditions. \r\n\r\nReviewers should verify this PR satisfies this list as well.\r\n\r\n- [ ] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [ ] This was checked for breaking HTTP API changes, and any breaking\r\nchanges have been approved by the breaking-change committee. The\r\n`release_note:breaking` label should be applied in these situations.\r\n- [ ] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n- [ ] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"720ddd716bda9210ca92d21b0ed7065554118859"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202833","number":202833,"mergeCommit":{"message":"Enhance access query logic to handle user ID and name conditions (#202833)\n\n[Obs AI Assistant] Fetch user instructions and conversation using user\r\nid instead of user name -\r\nhttps://github.com//issues/192701\r\n\r\nTo avoid potential collisions when fetching data, we should query for\r\nthe user id instead of the user name when getting instructions or\r\nconversations.\r\n\r\n**If user.id is provided:**\r\n - Matches documents with user.id equal to the provided value.\r\n - Falls back to user.name when user.id does not exist in the document.\r\n \r\n**If user.id is not provided:**\r\n - Matches only documents with user.name.\r\n\r\n## Summary\r\n\r\nSummarize your PR. If it involves visual changes include a screenshot or\r\ngif.\r\n\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following conditions. \r\n\r\nReviewers should verify this PR satisfies this list as well.\r\n\r\n- [ ] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [ ] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [ ] This was checked for breaking HTTP API changes, and any breaking\r\nchanges have been approved by the breaking-change committee. The\r\n`release_note:breaking` label should be applied in these situations.\r\n- [ ] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n- [ ] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"720ddd716bda9210ca92d21b0ed7065554118859"}}]}] BACKPORT--> Co-authored-by: Arturo Lidueña <[email protected]> Co-authored-by: Søren Louv-Jansen <[email protected]>
…stic#202833) [Obs AI Assistant] Fetch user instructions and conversation using user id instead of user name - elastic#192701 To avoid potential collisions when fetching data, we should query for the user id instead of the user name when getting instructions or conversations. **If user.id is provided:** - Matches documents with user.id equal to the provided value. - Falls back to user.name when user.id does not exist in the document. **If user.id is not provided:** - Matches only documents with user.name. ## Summary Summarize your PR. If it involves visual changes include a screenshot or gif. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] 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/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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 - [ ] 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) - [ ] 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. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] 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)
## Summary [Obs AI Assistant] Fetch user instructions using id instead of username for knowledge base instructions elastic#192701 To avoid potential collisions when fetching data, we should query for the user id instead of the user name when getting instructions.
…stic#202833) [Obs AI Assistant] Fetch user instructions and conversation using user id instead of user name - elastic#192701 To avoid potential collisions when fetching data, we should query for the user id instead of the user name when getting instructions or conversations. **If user.id is provided:** - Matches documents with user.id equal to the provided value. - Falls back to user.name when user.id does not exist in the document. **If user.id is not provided:** - Matches only documents with user.name. ## Summary Summarize your PR. If it involves visual changes include a screenshot or gif. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] 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/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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 - [ ] 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) - [ ] 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. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] 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)
Given we already store the profile_uid as the user id, to avoid potential collisions when fetching data, we should query for the user id instead of the user name when getting instructions. Currently we get the current user in the request and query with internalUser searching by the username.
Some background from kibana security:
When usernames are created in Elasticsearch's native realm, usernames are unique. The issue is that these are unique only within this native realm. If on-prem or ESS is configured with multiple realms (e.g., native + SAML/AD/OIDC/LDAP, like in ESS where we have Elastic Cloud via SAML + native users who can log in via Kibana's native login form), then we can potentially have users with the same username living in different security realms. Generally, we recommend using the profile ID, which is globally unique across all security realms (it has certain limitations that you should be aware of though: #175431 (comment)
The text was updated successfully, but these errors were encountered: