-
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
Gracefully disable favorites if profile is not available #204397
Gracefully disable favorites if profile is not available #204397
Conversation
packages/content-management/favorites/favorites_public/src/favorites_client.ts
Outdated
Show resolved
Hide resolved
…kibana into d/2024-12-16-favorites-edge-case
…kibana into d/2024-12-16-favorites-edge-case
Pinging @elastic/appex-sharedux (Team:SharedUX) |
packages/core/user-profile/core-user-profile-browser/src/service.ts
Outdated
Show resolved
Hide resolved
userProfile$: Observable<UserProfileData | null>; | ||
enabled$: Observable<boolean>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exposing enabled$
from core
@@ -470,22 +470,30 @@ export function HistoryAndStarredQueriesTabs({ | |||
const kibana = useKibana<ESQLEditorDeps>(); | |||
const { core, usageCollection, storage } = kibana.services; | |||
|
|||
const [starredQueriesService, setStarredQueriesService] = useState<EsqlStarredQueriesService>(); | |||
const [starredQueriesService, setStarredQueriesService] = useState< | |||
EsqlStarredQueriesService | null | undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding null
state for tracking when starredQueriesService
couldn't initialize and use it to hide the "starred" tab. intentionally showing "starred" tab during undefined
(loading) state because it is the most common scenario and we can avoid a content flash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core changes LGTM. Code review only.
packages/core/user-profile/core-user-profile-browser/src/service.ts
Outdated
Show resolved
Hide resolved
@Dosant can you provide steps on how to test it? |
…ce.ts Co-authored-by: Alejandro Fernández Haro <[email protected]>
@stratoula, imo the simplest would be to run any functional tests server from config from e.g.
another way is by configuring anonymous user https://www.elastic.co/guide/en/elasticsearch/reference/current/anonymous-access.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ES|QL changes LGTM, did a brief testing locally to ensure that it works as expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from the Platform Security perspective. Tested locally using anonymous access - favorite controls aren’t visible as expected, and the UI isn’t broken. However, I wish we could avoid throwing an exception when the profile isn’t available, as it’s a normal expected flow for certain configurations (adding a warn
favorites-specific log line would be much better, as having all user profile consumers throw errors could create a misleading perception).
@azasypkin, thanks, I'll double-check. I might have missed something when was changing the check to enabled$ Update: so it works without an error in console for ESQL favorites, but it becomes quite a bit large change to fix this in dashboard because logic to hide Starred tab relies on a thrown error and it is default react-query behaviour to log an error even when it is handled. |
…vorites-edge-case
const isAvailable = await client.isAvailable(); | ||
if (!isAvailable) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it worth extending this conditional check here to the dashboard list implementation to determine if favorites is enabled here https://github.com/elastic/kibana/blob/v8.17.0/packages/content-management/table_list_view_table/src/services.tsx#L278, especially that when we navigate to the dashboard listing page at attempt is still made to request favorites?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be ideal, but that check is async so I wanted to avoid additional changes.
I will take another look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just changed that isFavoritesEnabled to allow for Promise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also fixes @azasypkin's suggestion: #204397 (review)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this, UI to star entities doesn't get displayed for both ESQL and dashboard listing when the user profile isn't available, however for dashboard listing an request attempt is still being made to fetch the user's favourites.
verified using the following config to kibana.dev.yml
,
xpack.security.authc.providers:
basic.basic1:
order: 0
anonymous.anonymous1:
order: 1
credentials:
username: "elastic"
password: "changeme"
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
History
|
Starting backport for target branches: 8.x |
) ## Summary When a user profile is not available, the favorites (starred) service can't be used. On UI user profile can be not available if security is disabled or for an anonymous user. This PR improves the handling of starred features for rare cases when a profile is missing: - No unnecessary `GET favorites` requests that would fail with error and add noise to console/networks - No unhandled errors are thrown - Starred tab in esql is hidden - The Dashboard Starred tab isn't flickering on each attempt to fetch favorites For this needed to expose `userProfile.enabled$` from core, also created elastic#204570 ### Testing ``` node scripts/functional_tests_server.js --config test/functional/apps/dashboard/group4/config.ts localhost:5620 ``` another way is by configuring an anonymous user https://www.elastic.co/guide/en/elasticsearch/reference/current/anonymous-access.html (cherry picked from commit 70cf414)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…) (#205270) # Backport This will backport the following commits from `main` to `8.x`: - [Gracefully disable favorites if profile is not available (#204397)](#204397) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Anton Dosov","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-30T15:35:51Z","message":"Gracefully disable favorites if profile is not available (#204397)\n\n## Summary\r\n\r\nWhen a user profile is not available, the favorites (starred) service\r\ncan't be used. On UI user profile can be not available if security is\r\ndisabled or for an anonymous user.\r\n\r\nThis PR improves the handling of starred features for rare cases when a\r\nprofile is missing:\r\n\r\n- No unnecessary `GET favorites` requests that would fail with error and\r\nadd noise to console/networks\r\n- No unhandled errors are thrown\r\n- Starred tab in esql is hidden\r\n- The Dashboard Starred tab isn't flickering on each attempt to fetch\r\nfavorites\r\n\r\nFor this needed to expose `userProfile.enabled# Backport This will backport the following commits from `main` to `8.x`: - [Gracefully disable favorites if profile is not available (#204397)](#204397) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT from core, also created\r\nhttps://github.com//issues/204570\r\n\r\n\r\n\r\n### Testing \r\n\r\n```\r\nnode scripts/functional_tests_server.js --config test/functional/apps/dashboard/group4/config.ts\r\n\r\nlocalhost:5620\r\n```\r\n\r\nanother way is by configuring an anonymous user\r\nhttps://www.elastic.co/guide/en/elasticsearch/reference/current/anonymous-access.html","sha":"70cf414f42c3e7b0974cb8a3e508308f4206047e","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:SharedUX","backport:prev-minor"],"title":"Gracefully disable favorites if profile is not available","number":204397,"url":"https://github.com/elastic/kibana/pull/204397","mergeCommit":{"message":"Gracefully disable favorites if profile is not available (#204397)\n\n## Summary\r\n\r\nWhen a user profile is not available, the favorites (starred) service\r\ncan't be used. On UI user profile can be not available if security is\r\ndisabled or for an anonymous user.\r\n\r\nThis PR improves the handling of starred features for rare cases when a\r\nprofile is missing:\r\n\r\n- No unnecessary `GET favorites` requests that would fail with error and\r\nadd noise to console/networks\r\n- No unhandled errors are thrown\r\n- Starred tab in esql is hidden\r\n- The Dashboard Starred tab isn't flickering on each attempt to fetch\r\nfavorites\r\n\r\nFor this needed to expose `userProfile.enabled# Backport This will backport the following commits from `main` to `8.x`: - [Gracefully disable favorites if profile is not available (#204397)](#204397) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT from core, also created\r\nhttps://github.com//issues/204570\r\n\r\n\r\n\r\n### Testing \r\n\r\n```\r\nnode scripts/functional_tests_server.js --config test/functional/apps/dashboard/group4/config.ts\r\n\r\nlocalhost:5620\r\n```\r\n\r\nanother way is by configuring an anonymous user\r\nhttps://www.elastic.co/guide/en/elasticsearch/reference/current/anonymous-access.html","sha":"70cf414f42c3e7b0974cb8a3e508308f4206047e"}},"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/204397","number":204397,"mergeCommit":{"message":"Gracefully disable favorites if profile is not available (#204397)\n\n## Summary\r\n\r\nWhen a user profile is not available, the favorites (starred) service\r\ncan't be used. On UI user profile can be not available if security is\r\ndisabled or for an anonymous user.\r\n\r\nThis PR improves the handling of starred features for rare cases when a\r\nprofile is missing:\r\n\r\n- No unnecessary `GET favorites` requests that would fail with error and\r\nadd noise to console/networks\r\n- No unhandled errors are thrown\r\n- Starred tab in esql is hidden\r\n- The Dashboard Starred tab isn't flickering on each attempt to fetch\r\nfavorites\r\n\r\nFor this needed to expose `userProfile.enabled# Backport This will backport the following commits from `main` to `8.x`: - [Gracefully disable favorites if profile is not available (#204397)](#204397) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT from core, also created\r\nhttps://github.com//issues/204570\r\n\r\n\r\n\r\n### Testing \r\n\r\n```\r\nnode scripts/functional_tests_server.js --config test/functional/apps/dashboard/group4/config.ts\r\n\r\nlocalhost:5620\r\n```\r\n\r\nanother way is by configuring an anonymous user\r\nhttps://www.elastic.co/guide/en/elasticsearch/reference/current/anonymous-access.html","sha":"70cf414f42c3e7b0974cb8a3e508308f4206047e"}}]}] BACKPORT--> Co-authored-by: Anton Dosov <[email protected]>
) ## Summary When a user profile is not available, the favorites (starred) service can't be used. On UI user profile can be not available if security is disabled or for an anonymous user. This PR improves the handling of starred features for rare cases when a profile is missing: - No unnecessary `GET favorites` requests that would fail with error and add noise to console/networks - No unhandled errors are thrown - Starred tab in esql is hidden - The Dashboard Starred tab isn't flickering on each attempt to fetch favorites For this needed to expose `userProfile.enabled$` from core, also created elastic#204570 ### Testing ``` node scripts/functional_tests_server.js --config test/functional/apps/dashboard/group4/config.ts localhost:5620 ``` another way is by configuring an anonymous user https://www.elastic.co/guide/en/elasticsearch/reference/current/anonymous-access.html
) ## Summary When a user profile is not available, the favorites (starred) service can't be used. On UI user profile can be not available if security is disabled or for an anonymous user. This PR improves the handling of starred features for rare cases when a profile is missing: - No unnecessary `GET favorites` requests that would fail with error and add noise to console/networks - No unhandled errors are thrown - Starred tab in esql is hidden - The Dashboard Starred tab isn't flickering on each attempt to fetch favorites For this needed to expose `userProfile.enabled$` from core, also created elastic#204570 ### Testing ``` node scripts/functional_tests_server.js --config test/functional/apps/dashboard/group4/config.ts localhost:5620 ``` another way is by configuring an anonymous user https://www.elastic.co/guide/en/elasticsearch/reference/current/anonymous-access.html
) ## Summary When a user profile is not available, the favorites (starred) service can't be used. On UI user profile can be not available if security is disabled or for an anonymous user. This PR improves the handling of starred features for rare cases when a profile is missing: - No unnecessary `GET favorites` requests that would fail with error and add noise to console/networks - No unhandled errors are thrown - Starred tab in esql is hidden - The Dashboard Starred tab isn't flickering on each attempt to fetch favorites For this needed to expose `userProfile.enabled$` from core, also created elastic#204570 ### Testing ``` node scripts/functional_tests_server.js --config test/functional/apps/dashboard/group4/config.ts localhost:5620 ``` another way is by configuring an anonymous user https://www.elastic.co/guide/en/elasticsearch/reference/current/anonymous-access.html
Summary
When a user profile is not available, the favorites (starred) service can't be used. On UI user profile can be not available if security is disabled or for an anonymous user.
This PR improves the handling of starred features for rare cases when a profile is missing:
GET favorites
requests that would fail with error and add noise to console/networksFor this needed to expose
userProfile.enabled$
from core, also created #204570Testing
another way is by configuring an anonymous user https://www.elastic.co/guide/en/elasticsearch/reference/current/anonymous-access.html