You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
UploadMediaItem fails with cryptic error when the file length is zero #39
When a file length is zero, uploading it causes this exception:
java.lang.IllegalArgumentException: The upload was completed but failed to finalize or get the result.
at com.google.photos.library.v1.upload.PhotosLibraryUploadCallable.buildUploadMediaItemResponse(PhotosLibraryUploadCallable.java:314) ~[google-photos-library-client-1.5.0.jar:1.5.0]
at com.google.photos.library.v1.upload.PhotosLibraryUploadCallable.call(PhotosLibraryUploadCallable.java:184) ~[google-photos-library-client-1.5.0.jar:1.5.0]
at com.google.photos.library.v1.upload.PhotosLibraryUploadCallable.call(PhotosLibraryUploadCallable.java:45) ~[google-photos-library-client-1.5.0.jar:1.5.0]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:?]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
at java.lang.Thread.run(Unknown Source) ~[?:?]
I think PhotosLibraryUploadCallable should handle it better and fail fast with a more descriptive error.
The error is actually descriptive - the file was technically uploaded, but the Library API did not return a usable result (ie. an uploadToken). This could have different reasons , including an invalid file like in this case. Here the client library is mirroring the behaviour of the Library API itself and is passing through the response.
However - I agree that it would be nicer to fail early, especially for something that would never succeed. I will propose a change to add a check for the file size before an upload request is made. Failing with a IOException in PhotosLibraryUploadCallable#call()looks like the best option.
When a file length is zero, uploading it causes this exception:
I think PhotosLibraryUploadCallable should handle it better and fail fast with a more descriptive error.