googlephotos: fix nil panic in Update when using async batch_mode by davispw · Pull Request #9502 · rclone/rclone · GitHub
Skip to content

googlephotos: fix nil panic in Update when using async batch_mode#9502

Draft
davispw wants to merge 2 commits into
rclone:masterfrom
davispw:gphotos-async-panic
Draft

googlephotos: fix nil panic in Update when using async batch_mode#9502
davispw wants to merge 2 commits into
rclone:masterfrom
davispw:gphotos-async-panic

Conversation

@davispw

@davispw davispw commented Jun 7, 2026

Copy link
Copy Markdown

Summary

When batch_mode=async is configured, batcher.Commit returns immediately with a nil *api.MediaItem result (the actual commit happens later in a background goroutine). The old code passed this nil directly to o.setMetaData(info), which dereferenced it and panicked:

runtime error: invalid memory address or nil pointer dereference

This PR adds a defensive nil guard to setMetaData and updates Update to use the local size when the API response is deferred, preventing the crash.


Technical Details

  • Adds a nil guard in setMetaData(info) to handle deferred results from async batcher commits.
  • Uses src.Size() for o.bytes in Update when info == nil (so caching layers like the hasher overlay can immediately record the correct fingerprint).

Automated Tests

Adds the TestAsyncBatchModePanic regression test in backend/googlephotos/googlephotos_workaround_test.go verifying the fix under async mode.


Manual Verification

Run an upload/overwrite in async mode:

./rclone copy test_photo.jpg gphotos:album/rclone_PR4_Test \
  --gphotos-batch-mode=async --gphotos-batch-size=1 -v

Before the fix, this crashed immediately. After the fix, it succeeds without panic.


Dependencies (gh-stack)

This PR is independent and has no dependencies.


Was the change discussed in an issue or in the forum before?

As far as I know, this was not discussed previously.


Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

@davispw davispw force-pushed the gphotos-async-panic branch from bb9b8d9 to 8be1491 Compare June 13, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant