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
Fail early on import, and don't prompt to overwrite when failing #11059
Fail early on import, and don't prompt to overwrite when failing #11059
Conversation
we expect to get an array of objects, so show an error message if we find something that is not an array
I tried both cases: importing a non-JSON file and importing a JSON file with a syntax error (I tried twice: first, by removing a double quote, and second, by removing a comma). In all cases I get the same error message: "Saved Objects: The file could not be processed.". Is it possible to produce the new error message you introduced in this PR: "JSON format is invalid and can not be imported."? |
Those are actually the same case. Both make You should get the new error when importing a valid JSON file where the root element is not an array, like the example I linked to in the description. |
Ah, I think I understand now. The "JSON format" in the new error message introduced in this PR refers to the structure of the JSON that Kibana expects for saved objects JSON. I think perhaps we could change that message to something like "Saved objects file format is invalid and cannot be imported"? The fact that the file contains JSON seems like an implementation detail that the user shouldn't need to care about. |
I like it. PR updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
5.x 84d0d65 |
Closes #5694 and #11057
JSON.parse
fails, show error and exit earlyTo test, try importing this JSON file (from #5694).
Also try importing a file that is not valid json, by, say, removing a quote from the file.