kibana/x-pack/plugins/spaces
Kibana Machine 2135cf0ff9
[8.8] Handles non-existing objects in _copy_saved_objects API call (#158036) (#158399)
# Backport

This will backport the following commits from `main` to `8.8`:
- [Handles non-existing objects in _copy_saved_objects API call
(#158036)](https://github.com/elastic/kibana/pull/158036)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Jeramy
Soucy","email":"jeramy.soucy@elastic.co"},"sourceCommit":{"committedDate":"2023-05-24T16:20:46Z","message":"Handles
non-existing objects in _copy_saved_objects API call (#158036)\n\nCloses
#156791\r\n\r\n## Summary\r\n\r\nThis PR implements catching the error
thrown by the\r\nsaved_objects_exporter when an object is not found, and
responding with\r\na detailed 404 (\"Not Found\") rather than a generic
500 (\"Internal Server\r\nError\") response message.\r\n\r\n### Example
Response:\r\n```\r\n{\r\n \"statusCode\": 404,\r\n \"error\": \"Not
Found\",\r\n \"message\": \"Saved objects not found\",\r\n
\"attributes\": {\r\n \"objects\": [\r\n {\r\n \"id\":
\"7adfa750-4c81-11e8-b3d7-01146121b73d\",\r\n \"type\":
\"dashboard\"\r\n },\r\n {\r\n \"id\":
\"571aaf70-4c88-11e8-b3d7-01146121b73d\",\r\n \"type\": \"search\"\r\n
},\r\n {\r\n \"id\": \"d3d7af60-4c81-11e8-b3d7-01146121b73d\",\r\n
\"type\": \"index-pattern\"\r\n }\r\n ]\r\n }\r\n}\r\n```\r\n\r\n###
Testing\r\n\r\n1. Install sample flight data, find the id of the flights
dashboard SO\r\n2. Create an additional space 'b'\r\n3. Issue a request
to copy saved objects to space b\r\n```\r\nPOST
kbn:/api/spaces/_copy_saved_objects\r\n{\r\n \"spaces\": [\r\n \"b\"\r\n
],\r\n \"objects\": [\r\n {\r\n \"type\": \"dashboard\",\r\n \"id\":
\"7adfa750-4c81-11e8-b3d7-01146121b73e\"\r\n },\r\n {\r\n \"type\":
\"dashboard\",\r\n \"id\": \"7adfa750-4c81-11e8-b3d7-01146121b73f\"\r\n
},\r\n {\r\n \"type\": \"dashboard\",\r\n \"id\":
\"7adfa750-4c81-11e8-b3d7-01146121b73g\"\r\n }\r\n ]\r\n}\r\n```\r\n4.
Verify response\r\n```\r\n{\r\n \"statusCode\": 404,\r\n \"error\":
\"Not Found\",\r\n \"message\": \"Saved objects not found\",\r\n
\"attributes\": {\r\n \"objects\": [\r\n {\r\n \"type\":
\"dashboard\",\r\n \"id\": \"7adfa750-4c81-11e8-b3d7-01146121b73e\"\r\n
},\r\n {\r\n \"type\": \"dashboard\",\r\n \"id\":
\"7adfa750-4c81-11e8-b3d7-01146121b73f\"\r\n },\r\n {\r\n \"type\":
\"dashboard\",\r\n \"id\": \"7adfa750-4c81-11e8-b3d7-01146121b73g\"\r\n
}\r\n ]\r\n }\r\n}\r\n```\r\n5. Issue a request to copy the flights
dashboard SO\r\n6. Verify the usual response (200, missing
references)\r\n7. Issue a malformed request to copy an SO\r\n8. Verify
status 400 response with
details","sha":"1589547b6f143c45c782ed857902026af2e7e38a","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Security","Feature:Saved
Objects","Feature:Security/Spaces","backport:all-open","v8.9.0"],"number":158036,"url":"https://github.com/elastic/kibana/pull/158036","mergeCommit":{"message":"Handles
non-existing objects in _copy_saved_objects API call (#158036)\n\nCloses
#156791\r\n\r\n## Summary\r\n\r\nThis PR implements catching the error
thrown by the\r\nsaved_objects_exporter when an object is not found, and
responding with\r\na detailed 404 (\"Not Found\") rather than a generic
500 (\"Internal Server\r\nError\") response message.\r\n\r\n### Example
Response:\r\n```\r\n{\r\n \"statusCode\": 404,\r\n \"error\": \"Not
Found\",\r\n \"message\": \"Saved objects not found\",\r\n
\"attributes\": {\r\n \"objects\": [\r\n {\r\n \"id\":
\"7adfa750-4c81-11e8-b3d7-01146121b73d\",\r\n \"type\":
\"dashboard\"\r\n },\r\n {\r\n \"id\":
\"571aaf70-4c88-11e8-b3d7-01146121b73d\",\r\n \"type\": \"search\"\r\n
},\r\n {\r\n \"id\": \"d3d7af60-4c81-11e8-b3d7-01146121b73d\",\r\n
\"type\": \"index-pattern\"\r\n }\r\n ]\r\n }\r\n}\r\n```\r\n\r\n###
Testing\r\n\r\n1. Install sample flight data, find the id of the flights
dashboard SO\r\n2. Create an additional space 'b'\r\n3. Issue a request
to copy saved objects to space b\r\n```\r\nPOST
kbn:/api/spaces/_copy_saved_objects\r\n{\r\n \"spaces\": [\r\n \"b\"\r\n
],\r\n \"objects\": [\r\n {\r\n \"type\": \"dashboard\",\r\n \"id\":
\"7adfa750-4c81-11e8-b3d7-01146121b73e\"\r\n },\r\n {\r\n \"type\":
\"dashboard\",\r\n \"id\": \"7adfa750-4c81-11e8-b3d7-01146121b73f\"\r\n
},\r\n {\r\n \"type\": \"dashboard\",\r\n \"id\":
\"7adfa750-4c81-11e8-b3d7-01146121b73g\"\r\n }\r\n ]\r\n}\r\n```\r\n4.
Verify response\r\n```\r\n{\r\n \"statusCode\": 404,\r\n \"error\":
\"Not Found\",\r\n \"message\": \"Saved objects not found\",\r\n
\"attributes\": {\r\n \"objects\": [\r\n {\r\n \"type\":
\"dashboard\",\r\n \"id\": \"7adfa750-4c81-11e8-b3d7-01146121b73e\"\r\n
},\r\n {\r\n \"type\": \"dashboard\",\r\n \"id\":
\"7adfa750-4c81-11e8-b3d7-01146121b73f\"\r\n },\r\n {\r\n \"type\":
\"dashboard\",\r\n \"id\": \"7adfa750-4c81-11e8-b3d7-01146121b73g\"\r\n
}\r\n ]\r\n }\r\n}\r\n```\r\n5. Issue a request to copy the flights
dashboard SO\r\n6. Verify the usual response (200, missing
references)\r\n7. Issue a malformed request to copy an SO\r\n8. Verify
status 400 response with
details","sha":"1589547b6f143c45c782ed857902026af2e7e38a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/158036","number":158036,"mergeCommit":{"message":"Handles
non-existing objects in _copy_saved_objects API call (#158036)\n\nCloses
#156791\r\n\r\n## Summary\r\n\r\nThis PR implements catching the error
thrown by the\r\nsaved_objects_exporter when an object is not found, and
responding with\r\na detailed 404 (\"Not Found\") rather than a generic
500 (\"Internal Server\r\nError\") response message.\r\n\r\n### Example
Response:\r\n```\r\n{\r\n \"statusCode\": 404,\r\n \"error\": \"Not
Found\",\r\n \"message\": \"Saved objects not found\",\r\n
\"attributes\": {\r\n \"objects\": [\r\n {\r\n \"id\":
\"7adfa750-4c81-11e8-b3d7-01146121b73d\",\r\n \"type\":
\"dashboard\"\r\n },\r\n {\r\n \"id\":
\"571aaf70-4c88-11e8-b3d7-01146121b73d\",\r\n \"type\": \"search\"\r\n
},\r\n {\r\n \"id\": \"d3d7af60-4c81-11e8-b3d7-01146121b73d\",\r\n
\"type\": \"index-pattern\"\r\n }\r\n ]\r\n }\r\n}\r\n```\r\n\r\n###
Testing\r\n\r\n1. Install sample flight data, find the id of the flights
dashboard SO\r\n2. Create an additional space 'b'\r\n3. Issue a request
to copy saved objects to space b\r\n```\r\nPOST
kbn:/api/spaces/_copy_saved_objects\r\n{\r\n \"spaces\": [\r\n \"b\"\r\n
],\r\n \"objects\": [\r\n {\r\n \"type\": \"dashboard\",\r\n \"id\":
\"7adfa750-4c81-11e8-b3d7-01146121b73e\"\r\n },\r\n {\r\n \"type\":
\"dashboard\",\r\n \"id\": \"7adfa750-4c81-11e8-b3d7-01146121b73f\"\r\n
},\r\n {\r\n \"type\": \"dashboard\",\r\n \"id\":
\"7adfa750-4c81-11e8-b3d7-01146121b73g\"\r\n }\r\n ]\r\n}\r\n```\r\n4.
Verify response\r\n```\r\n{\r\n \"statusCode\": 404,\r\n \"error\":
\"Not Found\",\r\n \"message\": \"Saved objects not found\",\r\n
\"attributes\": {\r\n \"objects\": [\r\n {\r\n \"type\":
\"dashboard\",\r\n \"id\": \"7adfa750-4c81-11e8-b3d7-01146121b73e\"\r\n
},\r\n {\r\n \"type\": \"dashboard\",\r\n \"id\":
\"7adfa750-4c81-11e8-b3d7-01146121b73f\"\r\n },\r\n {\r\n \"type\":
\"dashboard\",\r\n \"id\": \"7adfa750-4c81-11e8-b3d7-01146121b73g\"\r\n
}\r\n ]\r\n }\r\n}\r\n```\r\n5. Issue a request to copy the flights
dashboard SO\r\n6. Verify the usual response (200, missing
references)\r\n7. Issue a malformed request to copy an SO\r\n8. Verify
status 400 response with
details","sha":"1589547b6f143c45c782ed857902026af2e7e38a"}}]}]
BACKPORT-->

Co-authored-by: Jeramy Soucy <jeramy.soucy@elastic.co>
2023-05-24 10:32:34 -07:00
..
common [Saved Objects] Migrates authorization logic from repository to security extension (#148165) 2023-02-15 10:25:05 -05:00
public Space switcher not visible when sidebar is expanded (Accessibility) (#154622) 2023-04-18 18:44:01 -04:00
server [8.8] Handles non-existing objects in _copy_saved_objects API call (#158036) (#158399) 2023-05-24 10:32:34 -07:00
jest.config.js [jest] update config files to get coverage per plugin (#111299) 2021-09-09 08:14:56 +02:00
kibana.jsonc [packages] migrate all plugins to packages (#148130) 2023-02-08 21:06:50 -06:00
README.md Deprecate disabling the spaces plugin (#83984) 2020-12-02 12:00:14 -05:00
tsconfig.json [Saved Objects] Migrates authorization logic from repository to security extension (#148165) 2023-02-15 10:25:05 -05:00

Kibana Spaces Plugin

See Configuring Kibana Spaces.

The spaces plugin enables Kibana Spaces, which provide isolation and organization for saved objects.

Spaces also allow for a creating a curated Kibana experience, by hiding features that aren't relevant to your users.

Spaces can be combined with Security to further enhance the authorization model.