Skip to content
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

Panic is produced when adding media items to an album #54

Closed
pacoorozco opened this issue Jan 4, 2021 · 2 comments
Closed

Panic is produced when adding media items to an album #54

pacoorozco opened this issue Jan 4, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@pacoorozco
Copy link
Member

Describe the bug
The bug was reported on gphotosuploader/gphotos-uploader-cli#262. In some cases (I don't know when) Google Photos response include no MediaItem. The code panics when it tries to access to a nil MediaItem.

To Reproduce
When creating a media item the lines:

       mediaItemsResult := make([]MediaItem, len(result.NewMediaItemResults))
	for i, res := range result.NewMediaItemResults {
		m := res.MediaItem
		mediaItemsResult[i] = r.convertPhotosLibraryMediaItemToMediaItem(m)
	}

If result.NewMediaItemResults has some MediaItem pointing to nil, the code fails when it tries to access to it.

Expected behavior
It should not panic.

Additional context
The Google Photos API documentation is not saying anything about MediaItem pointing to nil on successful responses..

@pacoorozco
Copy link
Member Author

Google Photos API could return a empty MediaItem when an error has occurred. In that case the response has a Status addressing the problem.

It's documented here

In that case, we are going to skip this returned value.

@pacoorozco
Copy link
Member Author

Merged on master, v2.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant