-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
JSON file read/write errors / corruption causing crash #4841
Comments
does your config file run through jsonlint fine? |
@leadboots5 yup, valid JSON |
I don't know why but after deleting everything and run installation again, the bot is back to work with exactly the same config files... The only difference is I'm using dev branch now. So you guys may keep this open for further debugging if necessary. |
it's something to do with inventory-USERNAME.json file under web/ |
Yes, it is. The file can get corrupted if the bot is stopped while this file is open for write. Next time, just delete web/inventory-USERNAME.json and restart. |
I'll leave this open for debugging. Sorry, can't do it now. Will be tomorrow morning (AEST) then I'll see what I can do. |
@Gobberwart we have the inventory data in the database and probably can get it from the server. can't we just use that? |
@Gobberwart have you been able to replicate this? |
@Jasperrr91 I personally have not, but we have had a decent number of folks who end up needing to delete one or more of the web json files to stop such errors. |
Ah yes, I wrongfully assumed this was about the config.json but now I see it's about the web_inventory. If anyone experiences these errors. Please post a dump of the web jsons. (Or are there already any posted @mjmadsen?) |
I don't think so @Jasperrr91 But as @rawgni said, we should be using our db instead (same with the live_update). |
@Jasperrr91 I have seen it happen. Not sure exactly what causes it tbh. Best guess is an IO conflict. It's a very rare occurrence which makes it tricky to debug. @mjmadsen Agreed re the database. For now, I'll put some exception catching around the file reads/writes to hopefully suppress this crash, then we can look into using the db better. |
@rawgni Annoyingly, the inventory file contains both inventory and player data. Not sure who made that choice, but that's what the web interface wants. Overwriting the whole .json file with inventory data is simple, but the player data is (currently) not that simple and needs an api call. Therefore the method opens the .json file, removes all the "inventory" stuff, then writes it back from what's kept in the bot's internal memory, and keeps the player data in tact. If there were separate outfiles for each (player data, inventory (items) and pokemons), that would be a lot simpler to work with. |
@Gobberwart I think that choice was made because the inventory and player data is also grouped together in the API call. We're using an old commit of the Web interface so branching that and splitting the file shouldn't be too much of a hassle. But you still have to work with a JSON file that can give read/write errors. So although it may simplify things, it will not solve this particular bug. What will solve this, is adding a try/catch. I'll put out a PR request in the morning. Edit: Sorry, didn't read the rest of your first message. You already came up with that haha. Nvm me then. |
@Jasperrr91 I'm already working on try/catch. PR should be up in a minute. |
PR #4877 up for review. |
Closing #4841 |
Expected Behavior
Bot can start normally
Actual Behavior
Bot could not start with
ValueError("No JSON object could be decoded")
Your FULL config.json (remove your username, password, gmapkey and any other private info)
Output when issue occurred
Steps to Reproduce
Yesterday it was still running fine. Tried to start it for today and got this error.
Other Information
OS: OSx
Branch: master
Git Commit: ed09593
Python Version: 2.7.10
Any other relevant files/configs (eg: path files)
Path file:
The text was updated successfully, but these errors were encountered: