#1267·whatsmeow

qrchan: RotateADVSecret handler falls through and closes QR channel with empty event

Author: AOrobatorCreated Sep 15, 2026Updated Sep 15, 2026

Summary

Since 9ec8f76 ("pair: add untested support for companion_reg_refresh"), the *events.RotateADVSecret case in qrChannel.handleEvent (qrchan.go) is missing a return. After forwarding the event to qrc.rotateAdv, execution falls out of the switch into the channel-closing tail, so the QR channel is closed and a zero-value QRChannelItem{} (empty Event) is emitted.

Any client that treats unknown QR channel events as fatal now fails pairing the moment the server sends a companion_reg_refresh notification. Observed via wacli 0.18.2 (pinned at b25a56d63729): scanning the QR on iPhone produces

unsupported QR pairing state ""; update wacli and try again

Every other non-returning case in that switch assigns outputType before reaching the tail, so the empty event can only come from this path.

Reproduction

  1. Build any client against a whatsmeow commit at or after 9ec8f76 and consume GetQRChannel.
  2. Start pairing and scan the QR from a phone whose account triggers the companion_reg_refresh flow.
  3. Observe the QR channel closes with an item whose Event == "" instead of continuing with rotated codes.

Fix

Return after handing the rotation to the emitter, matching the intent of the commit (the emitter goroutine rewrites the remaining codes with the new secret):

diff
--- a/qrchan.go
+++ b/qrchan.go
@@ -150,6 +150,7 @@ func (qrc *qrChannel) handleEvent(rawEvt any) {
 		default:
 			qrc.log.Warnf("Rotate ADV channel didn't accept event")
 		}
+		return
 	case *events.QRScannedWithoutMultidevice:
 		qrc.log.Debugf("QR code scanned without multidevice enabled")
 		qrc.output <- QRChannelScannedWithoutMultidevice

Verified: with this one-line change applied at b25a56d63729 and wacli 0.18.2 rebuilt against it, QR pairing on an iPhone account completed and history sync started normally.

Environment

  • whatsmeow b25a56d63729 (2026-09-09); still present on main at 0d3b644 (2026-09-14)
  • macOS arm64, Go 1.27.1
  • WhatsApp on iPhone