[Synthetics] Validate private location spaces for multi-space monitors#260642
Conversation
💔 Build Failed
Failed CI StepsTest Failures
Metrics [docs]Async chunks
History
cc @benakansara |
Catch flakiness early (recommended)Recommended before merge: run the flaky test runner against this PR to catch flakiness early. New async API calls ( Trigger a run with the Flaky Test Runner UI or post this comment on the PR: Share feedback in the #appex-qa channel. Posted via Macroscope — Flaky Test Runner nudge |
cauemarcondes
left a comment
There was a problem hiding this comment.
Obs UI changes LGTM
| server.security.authz.checkSavedObjectsPrivilegesWithRequest(request); | ||
|
|
||
| const { hasAllRequested } = await checkSavedObjectsPrivileges( | ||
| 'saved_object:synthetics-monitor/bulk_update', |
There was a problem hiding this comment.
| 'saved_object:synthetics-monitor/bulk_update', | |
| 'synthetics-monitor-multi-space/bulk_update' //. or it would synthetics-monitor depending on type, |
i just realized this is a bug,synthetics-monitor is only single space monitor, when we start supporting multi space monitor, you will need to check against synthetics-monitor-multi-space
so i think in edit route when you fetch saved object, you can see it's type and based on that we will need to check which saved object to use.
💚 Build Succeeded
Metrics [docs]Async chunks
History
cc @benakansara |
elastic#260642) Resolves elastic#233434, elastic#247904 ## Summary Multi-space monitors can reference private locations that are not shared to all the monitor's spaces. This caused confusing red error boxes in the UI when editing from a space where the location isn't available, and allowed invalid monitor configurations to be persisted silently. This PR adds server-side validation to enforce that every private location assigned to a monitor is available in all spaces the monitor is shared to, for both UI and project monitors. It also improves the UI to surface a clear, actionable warning when a selected private location is not available in all monitor spaces. ## Testing ### Prerequisites - Two spaces: default and space-a - A private location shared only to default (not space-a) - A user with monitor permissions in both spaces ### UI monitor - create - From default space, create a monitor. - Set Kibana spaces to [default, space-a]. - Select the private location (shared only to default space). - Expected: Save is blocked with: "The following private locations are not available in all spaces this monitor is shared to: <name>. Either share the private locations to all monitor spaces, or remove those spaces from the monitor." - Also verify a red warning appears below the locations picker before even saving. ### UI monitor - edit **Step 1 - Create the bad state on main** - Make sure you have two spaces: default and space-a - Create a private location - Share the private location only to default space (not space-a) - Go to Synthetics -> Create Monitor from default space - Set Kibana spaces to [default, space-a] - Select the private location - Save - it will succeed (no validation on main) **Step 2 - Switch back to PR branch** **Step 3 - Test the edit flow** - Scenario A - edit from default space (where private location exists): - Open the monitor from default space - Make any change (e.g. change the monitor name) - Click Save - Expected: 400 error: "The following private locations are not available in all spaces this monitor is shared to: <name>. Either share the private locations to all monitor spaces, or remove those spaces from the monitor." - Also verify the red warning text is visible below the locations picker - Scenario B - edit from space-a (where private location is not available): - Switch to space-a - Open the same monitor - Expected: The private location chip appears in red in the locations field, and the red warning message is shown below the combo box - Try to save -> same 400 error as Scenario A - Scenario C - fix and save: - From either space, remove space-a from the spaces field (or remove the private location) - Save - Expected: Saves successfully, no error ### Authorization check - As a user with monitor permissions in default but not space-a, open a monitor shared to both spaces. - Try to save any change. - Expected: 403 error: "This monitor is shared to spaces where you do not have update permissions. To save changes, either request access to those spaces or remove them from the monitor." ### Project monitors - Push a project monitor config with a private location that isn't shared to all the monitor's spaces. - Expected: API returns a validation error identifying the location and missing spaces. ### Monitors with only public locations - Monitors using only public locations should create/edit without any new errors. ### Single-space monitors - Monitors in a single space with a private location in that space should work as before. --------- Co-authored-by: Shahzad <shahzad31comp@gmail.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
PR elastic#270540's monitor_integration_health_api.{ts,test.ts} import getPrivateLocationsForNamespaces, which was added on main by PR elastic#260642 but does not exist on 9.4 yet — causing 5 type errors in CI. Port the symbol verbatim from main: add the multi-namespace export and rewrite getPrivateLocations as a one-line wrapper. The public signature of getPrivateLocations is preserved, so all existing 9.4 callers are unaffected. Co-authored-by: Cursor <cursoragent@cursor.com>
Resolves #233434, #247904
Summary
Multi-space monitors can reference private locations that are not shared to all the monitor's spaces. This caused confusing red error boxes in the UI when editing from a space where the location isn't available, and allowed invalid monitor configurations to be persisted silently.
This PR adds server-side validation to enforce that every private location assigned to a monitor is available in all spaces the monitor is shared to, for both UI and project monitors. It also improves the UI to surface a clear, actionable warning when a selected private location is not available in all monitor spaces.
Testing
Prerequisites
UI monitor - create
UI monitor - edit
Step 1 - Create the bad state on main
Step 2 - Switch back to PR branch
Step 3 - Test the edit flow
Scenario A - edit from default space (where private location exists):
Scenario B - edit from space-a (where private location is not available):
Scenario C - fix and save:
Authorization check
Project monitors
Monitors with only public locations
Single-space monitors