restoreFromTrash Api error SyntaxError: "undefined" is not valid JSON
Hello,
I have a lot of photos in the trash, and my goal is to restore only those photos/videos which are not taking up space in the account storage (once restored), is it possible to add such feature to the toolkit ? As a workaround, I'm first trying to restore them all and then moving to trash the photos/videos which are taking space (this is supported by the toolkit).
However, restoring from trash fails at random time, log:
[05:30:51] Getting trash items
[05:30:52] Found 500 items
[05:30:52] Found 500 items
[05:30:53] Found 500 items
[05:30:54] Found 500 items
[05:30:54] Found 499 items
[05:30:55] Found 500 items
[05:30:55] Found 500 items
[05:30:56] Found 500 items
[05:30:57] Found 500 items
[05:30:58] Found 500 items
[05:30:58] Found 500 items
[05:30:59] Found 500 items
[05:30:59] Found 500 items
[05:31:00] Found 500 items
[05:31:01] Found 500 items
[05:31:01] Found 500 items
[05:31:02] Found 500 items
[05:31:02] Found 500 items
[05:31:03] Found 500 items
[05:31:03] Found 500 items
[05:31:04] Found 500 items
[05:31:04] Found 500 items
[05:31:05] Found 500 items
[05:31:06] Found 500 items
[05:31:06] Found 500 items
[05:31:07] Found 500 items
[05:31:07] Found 500 items
[05:31:08] Found 500 items
[05:31:09] Found 500 items
[05:31:09] Found 500 items
[05:31:10] Found 500 items
[05:31:10] Found 500 items
[05:31:11] Found 500 items
[05:31:11] Found 500 items
[05:31:12] Found 500 items
[05:31:13] Found 500 items
[05:31:13] Found 500 items
[05:31:14] Found 500 items
[05:31:14] Found 500 items
[05:31:15] Found 500 items
[05:31:15] Found 500 items
[05:31:16] Found 500 items
[05:31:17] Found 500 items
[05:31:17] Found 500 items
[05:31:18] Found 500 items
[05:31:19] Found 500 items
[05:31:19] Found 500 items
[05:31:20] Found 491 items
[05:31:20] Found 497 items
[05:31:21] Found 494 items
[05:31:22] Found 496 items
[05:31:22] Found 500 items
[05:31:23] Found 489 items
[05:31:24] Found 495 items
[05:31:24] Found 490 items
[05:31:25] Found 488 items
[05:31:25] Found 496 items
[05:31:26] Found 495 items
[05:31:26] Found 480 items
[05:31:27] Found 473 items
[05:31:27] Found 496 items
[05:31:28] Found 497 items
[05:31:29] Found 490 items
[05:31:29] Found 491 items
[05:31:30] Found 496 items
[05:31:30] Found 497 items
[05:31:31] Found 492 items
[05:31:31] Found 500 items
[05:31:32] Found 500 items
[05:31:33] Found 499 items
[05:31:33] Found 496 items
[05:31:34] Found 498 items
[05:31:34] Found 500 items
[05:31:35] Found 500 items
[05:31:36] Found 500 items
[05:31:36] Found 500 items
[05:31:37] Found 500 items
[05:31:37] Found 500 items
[05:31:38] Found 500 items
[05:31:39] Found 500 items
[05:31:39] Found 500 items
[05:31:40] Found 500 items
[05:31:40] Found 500 items
[05:31:41] Found 500 items
[05:31:41] Found 500 items
[05:31:42] Found 500 items
[05:31:42] Found 500 items
[05:31:43] Found 500 items
[05:31:43] Found 500 items
[05:31:44] Found 500 items
[05:31:45] Found 349 items
[05:31:45] Source read complete
[05:31:45] Found items: 45184
[05:31:45] Filtering by date
[05:31:45] Item count after filtering: 45144
[05:31:45] Filtering by media type
[05:31:45] Item count after filtering: 41424
[05:31:45] Items to process: 41424
[05:31:45] Restoring 41424 items from trash
[05:31:45] Processing 500 items
[05:31:45] Processing 500 items
[05:31:45] Processing 500 items
[05:33:45] restoreFromTrash Api error SyntaxError: "undefined" is not valid JSON
[05:33:45] SyntaxError: "undefined" is not valid JSON at JSON.parse (
I have to repeat the trash restore request over and over again until at the end, hopefully there are only a few or 0 items left to process.
There is about 55 days left until the trash will be automatically emptied, so hope this bug will be fixed before then.
I have a lot of photos in the trash, and my goal is to restore only those photos/videos which are not taking up space in the account storage (once restored), is it possible to add such feature to the toolkit ?
Api limitations, there is no way to get that info in batches for items in the trash.
However, restoring from trash fails at random time,
Does restoring them manually in batches of 500 works?
Try lowering API operation batch size in the advanced settings until the error goes away.
Api limitations, there is no way to get that info in batches for items in the trash.
OK
Does restoring them manually in batches of 500 works? Try lowering
API operation batch sizein the advanced settings until the error goes away.
With the default batch size of 500 I got down to 3592 items left, and now further repeats won't decrease the number (getting this error): [06:53:27] restoreFromTrash Api error TypeError: Cannot read properties of null (reading '0') [06:53:27] TypeError: Cannot read properties of null (reading '0') at Api.restoreFromTrash (chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/userscript.html?name=Google-Photos-Toolkit.user.js&id=e979dbeb-08ac-4c40-baf8-e74f2798125c:1455:24)
Then lowered the batch size to 100 and I got down to 3460 items left (same error as above).
Now with batch size of 10 I got down to 3420 items left (same error).
So far looking good with batch size of 5.
2335 items left now and can't get any lower, even with batch size of 1.
Edit: Reducing Max Concurrent Api Requests from 3 to 1 helped.
Both API operation batch size and Max Concurrent Api Requests are set to 1, but I'm stuck at 2257 items left.
Any suggestions ?
OK, I think I found the cause: Tried restoring 1 item manually and got error "Not enough storage to restore. You don't have enough space to restore photos & videos. To continue, get more storage with Google One or clean up your existing storage." even though I got 187.8 GB of 200 GB used.
Process completed now after moving a couple of large videos to trash.
Suggest adding an exception handling for out of storage.
Hi,
Getting a similar issue whenever I select "Exclude media with shared links", regardless of how many photos are selected and API parameters :
[15:12:56] Found 40 items
[15:12:56] Found 1 items
[15:12:56] Found 1 items
[15:12:56] Found 1 items
[15:12:56] Found 1 items
[15:12:56] Found 1 items
[15:12:56] Found 40 items
[15:12:56] SyntaxError: "undefined" is not valid JSON at JSON.parse (
Hopefully the issue can be found, I don't think this case quite overlaps with the one previously mentionned