Fail early on import, and don't prompt to overwrite when failing (#11059)

* stop importing if JSON parsing fails

* fail early if improper JSON

we expect to get an array of objects, so show an error message if we find something that is not an array

* clarify import error message
This commit is contained in:
Joe Fleming 2017-04-10 11:39:09 -07:00 committed by Joe Fleming
parent 3fa65e3855
commit 84d0d65540

View file

@ -164,6 +164,13 @@ uiModules.get('apps/management')
docs = JSON.parse(fileContents);
} catch (e) {
notify.error('The file could not be processed.');
return;
}
// make sure we have an array, show an error otherwise
if (!Array.isArray(docs)) {
notify.error('Saved objects file format is invalid and cannot be imported.');
return;
}
return new Promise((resolve) => {