Skip to content
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

Copy saved object in Spaces API not returning response according to documentation #77616

Closed
emilygray0702 opened this issue Sep 16, 2020 · 4 comments
Labels
Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!

Comments

@emilygray0702
Copy link

Kibana version: 7.8

Elasticsearch version: 7.8

Server OS version: CentOS 7 (Docker container)

Original install method (e.g. download page, yum, from source, etc.): official Elastic Docker images

Describe the bug: I used /api/spaces/_copy_saved_objects to copy a dashboard from the default space to another space. It returned with successCount 4 (I was only copying one dashboard, but possibly there were references copied as well), but no successResults array. It says in the documentation that information about the object(s) copied should be returned there. The dashboard was copied successfully.

Steps to reproduce:

  1. Create dashboard in default space and create other space.
  2. Execute
curl -X POST http://<your IP>/api/spaces/_copy_saved_objects -H 'Content-Type: application/json' -H 'kbn-xsrf: true' -d '{
  "objects": [
      {
        "type":"dashboard",
        "id":"<dashboard ID>"
      } 
  ],
  "spaces": [
      "<space ID>"
  ],
  "includeReferences":true,
  "overwrite":true
}'

Expected behavior:
successResults in response body

Response body:
{"<space ID>":{"success":true,"successCount":4}}

@pmuellr pmuellr added the Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc label Sep 16, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

@legrego legrego added Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! and removed Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels Sep 16, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

@pmuellr
Copy link
Member

pmuellr commented Sep 16, 2020

Looking at the code, it does appear that the successResults is no longer returned - not sure if this is a doc error, or if the code should be returning this, but isn't anymore.

doc: https://github.com/elastic/kibana/blob/master/docs/api/spaces-management/copy_saved_objects.asciidoc

code:

const copyResponse = await copySavedObjectsToSpaces(sourceSpaceId, destinationSpaceIds, {
objects,
includeReferences,
overwrite,
createNewCopies,
});
return response.ok({ body: copyResponse });

const copySavedObjectsToSpaces = async (
sourceSpaceId: string,
destinationSpaceIds: string[],
options: CopyOptions
): Promise<CopyResponse> => {
const response: CopyResponse = {};
const exportedSavedObjects = await exportRequestedObjects(sourceSpaceId, options);
const ineligibleTypes = getIneligibleTypes(getTypeRegistry());
const filteredObjects = exportedSavedObjects.filter(
({ type }) => !ineligibleTypes.includes(type)
);
for (const spaceId of destinationSpaceIds) {
response[spaceId] = await importObjectsToSpace(
spaceId,
createReadableStreamFromArray(filteredObjects),
options
);
}
return response;
};

@legrego
Copy link
Member

legrego commented Sep 16, 2020

Hi @emilygray0702,

The successResults array that you're looking for is not available in version 7.8. The docs for 7.8 don't make reference to this: https://www.elastic.co/guide/en/kibana/7.8/spaces-api-copy-saved-objects.html

successResults was introduced via #75444, which is scheduled to be released with version 7.10

@legrego legrego closed this as completed Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!
Projects
None yet
Development

No branches or pull requests

4 participants