Not valid JSON: EOF
Getting this error when trying to import a file with CLI command
Importing data from "./data/temp_quotes_data.json" to table "temp_quotes" failed Not valid JSON: EOF while parsing a string at line 302 column 9I have prettier as formatter and I see it adds a new line at the end of the file. Could that be affecting?
26 Replies
this is what the file looks like at line 302 col 9
Addresses in JSON parse errors are always post some sort of internal formatting, probably doesn’t map to your input file as is. More likely that there’s a legitimate syntax error somewhere, probably involving quotation marks.
If you have jq installed you can see if you can get a better error message:
@erquhart ran it but returns empty
i'm extracting fields fine with jq
no errors
🤔
i'm using MacOS
The error says EOF while parsing a string, any chance the file is massive? If so I wonder if it's being truncated at some point in the import process.
Yeah that command was just to check validity, sounds like it is. According to jq, anyway, but json validity is a moving target. Maybe the Convex team will have some insight.
it is a couple of MB
@ian any idea on what can be happening?
A couple of MB shouldn't be an issue. @lee A couple thoughts:
1. In VSCode settings set "Render Whitespace" to "all" in case there are hidden characters like some null terminator.
2. Try running it with the first half of the file and see if it's an issue, or just the first row, and bisect to see if it's a certain entry.
3. You're on the latest Convex? @lee improved import in the last few weeks to handle huge imports/exports. It could have previously been terminating after some limit - maybe even as low as 4MB but don't quote me on that. It should be more scalable post 1.9 iirc.
4. Run
jq -c '.[]' ./data/temp_quotes_data.json > temp_quotes_data.jsonl
and try importing the jsonl
format, which can scan line by line rather than needing to load it all at once as an array.converting to jsonl will probably work. i should look into where this error is coming from, but it definitely looks like the json is being truncated, which wouldn't be a problem with jsonl
i'll try this. that jq command looks awesome
i converted the file to jsonl and now i get this error
is this import command importing to Dev or Prod?
my intention is to Dev
dev is the default
Assuming you tried more than once and got the same error?
i see this error in dev
i'll try with the optional for supplier field
running "convex": "^1.10.0",
Yeah looks like the imported data is legitimately failing schema validation. You could also just turn off schema validation before the import if you know it doesn't matter.
Might be nice to have a flag for that actually
that
optional
worked!
so it was helpful to run convex dev
side by side with the convex import
so i could see the errorsNice! The error from the import command was basically incorrect, though, so that could be improved. cc/ @lee
yeah, that would've been very quick to debug
i don't understand why
npx convex import
would throw that error unless you're actively changing the schema. if the data doesn't match the schema, it throws a different errori think it was throwing the "schema change error" because the json was not matching 100% my schema
but it wasn't saying what field was mismatching
until i ran
convex dev
i saw exactly what was the mismatchIf dev wasn't running then schema change wouldn't really be happening
i ran the schema change with dev and then i stopped it so i would run the import
when i try an import that doesn't match the schema, i get
i ran the schema change with dev and then i stopped it so i would run the importah that's probably it. if the dev command doesn't finish, the schema might still be trying to commit on the server i'm surprised retries wouldn't work though
yeah maybe it was not done. i've been having a lot of delays when running dev in this project
i'll remove all the heavy files from the convex directory
that seems to help
cool. we're working on performance of
npx convex dev
, so hopefully that won't be necessary for long
btw i found the Not valid JSON: EOF while parsing a string at line 302 column 9
error and improved the error message to recommend the jq
command to create JSONLineseven when i had dev running, updated schema and imported, i noticed the schema failed. but dev said all was in sync before throwing the import error. then it synced again and the next import worked. so seems like dev saved changes after each import attempt instead of after saving the schema file