Details
-
Bug
-
Status: Accepted
-
Minor - P4
-
Resolution: Unresolved
-
100.7.0
-
None
-
OS: Ubuntu 22.04
-
Not Needed
Description
Problem Statement/Rationale
mongoimport fails when importing an empty JSON array, and emits an error. Instead, it should successfully import 0 records and exit.
Steps to Reproduce
- Create file empty-json-array.json, with contents []
- Replace placeholders as appropriate, then run:
mongoimport --uri <uri> --db <db> --collection <collection> --type json --jsonArray --file empty-json-array.json
Expected Results
A successful import with no errors reported
Actual Results
Failed: error processing document #1: invalid character ']' looking for beginning of value |
Additional Notes
Version:
mongoimport version: 100.7.0 |
git version: 17946f45f5fabfcdd99f8960b9109f976d370631
|
Go version: go1.19.3 |
os: linux
|
arch: amd64
|
compiler: gc
|
Solution
We will make mongoimport accept a file with an empty JSON array in it. When it encounters such a file, it will log a message saying that this file will be skipped because it does not contain any documents. This message will be logged at the Info level.