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

Saved object import shows inaccurate error count #68958

Closed
jportner opened this issue Jun 11, 2020 · 3 comments · Fixed by #75444
Closed

Saved object import shows inaccurate error count #68958

jportner opened this issue Jun 11, 2020 · 3 comments · Fixed by #75444
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages Feature:Saved Objects Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!

Comments

@jportner
Copy link
Contributor

jportner commented Jun 11, 2020

Kibana version: 7.8

Describe the bug: When processing a saved object import that results in reference errors, the error count is inaccurate.

Steps to reproduce:

  1. Start Kibana and load up eCommerce sample data
  2. Delete the index pattern
  3. Export the Dashboard, including references
  4. Import the new NDJSON file

Expected behavior: The error count should equal 9, instead it appears to be 16.

Screenshots (if relevant):

"Import saved objects" flyout:

image

Debugging and checking the object state reveals that several duplicates of import objects are included:

image

@jportner jportner added bug Fixes for quality problems that affect the customer experience Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! triaged labels Jun 11, 2020
@jportner jportner self-assigned this Jun 11, 2020
@elasticmachine
Copy link
Contributor

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

@jportner
Copy link
Contributor Author

This is happening because some objects have multiple references to an index pattern, and each reference is getting counted as an error (line 72):

export function processImportResponse(
response: SavedObjectsImportResponse
): ProcessedImportResponse {
// Go through the failures and split between unmatchedReferences and failedImports
const failedImports = [];
const unmatchedReferences = new Map();
for (const { error, ...obj } of response.errors || []) {
failedImports.push({ obj, error });
if (error.type !== 'missing_references') {
continue;
}
// Currently only supports resolving references on index patterns
const indexPatternRefs = error.references.filter((ref) => ref.type === 'index-pattern');
for (const missingReference of indexPatternRefs) {
const conflict = unmatchedReferences.get(
`${missingReference.type}:${missingReference.id}`
) || {
existingIndexPatternId: missingReference.id,
list: [],
newIndexPatternId: undefined,
};
conflict.list.push(obj);
unmatchedReferences.set(`${missingReference.type}:${missingReference.id}`, conflict);
}
}
return {
failedImports,
unmatchedReferences: Array.from(unmatchedReferences.values()),
// Import won't be successful in the scenario unmatched references exist, import API returned errors of type unknown or import API
// returned errors of type missing_references.
status:
unmatchedReferences.size === 0 &&
!failedImports.some((issue) => issue.error.type === 'conflict')
? 'success'
: 'idle',
importCount: response.successCount,
conflictedSavedObjectsLinkedToSavedSearches: undefined,
conflictedSearchDocs: undefined,
};
}

@rudolf rudolf added Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages Feature:Saved Objects labels Jul 6, 2020
jportner added a commit to jportner/kibana that referenced this issue Aug 19, 2020
@legrego
Copy link
Member

legrego commented Aug 27, 2020

Resolved via #75444

@legrego legrego closed this as completed Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages Feature:Saved Objects Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants