wechaty/wechaty · warning

find() all %d rooms are invalid

Error message

find() all %d rooms are invalid

What it means

Room.find() got a list of candidate rooms but puppet.roomValidate() rejected every one of them, so find() logs this warning and returns undefined. The ids exist in search results but are not confirmed as valid rooms by the puppet implementation.

Source

Thrown at src/user-modules/room.ts:241

    }

    if (roomList.length > 1) {
      log.warn('Room', 'find() got more than one(%d) result', roomList.length)
    }

    for (const [ idx, room ] of roomList.entries()) {
      // use puppet.roomValidate() to confirm double confirm that this roomId is valid.
      // https://github.com/wechaty/wechaty-puppet-padchat/issues/64
      // https://github.com/wechaty/wechaty/issues/1345
      const valid = await this.wechaty.puppet.roomValidate(room.id)
      if (valid) {
        log.verbose('Room', 'find() room<id=%s> is valid: return it', idx, room.id)
        return room
      } else {
        log.verbose('Room', 'find() room<id=%s> is invalid: skip it', idx, room.id)
      }
    }
    log.warn('Room', 'find() all %d rooms are invalid', roomList.length)
    return undefined
  }

  /**      const roomList: RoomInterface[] = []

   * @ignore
   *
   * Instance Properties
   *
   *
   */
  payload?: PUPPET.payloads.Room

  /**
   * @hideconstructor
   * @property {string}  id - Room id.
   * This function is depending on the Puppet Implementation, see [puppet-compatible-table](https://github.com/wechaty/wechaty/wiki/Puppet#3-puppet-compatible-table)
   */

View on GitHub (pinned to 5a0520ac7d)

Solutions

  1. Clear the puppet's room cache / restart the bot so payloads are refreshed
  2. Verify with room.say()-free checks like room.sync() or re-searching by id
  3. Confirm the bot is still a member of the target group
  4. Update/switch the puppet implementation if roomValidate is known-buggy

Example fix

// before
const room = await bot.Room.find({ topic: 'Dev Team' })
await room.say('hi') // room may be undefined
// after
const room = await bot.Room.find({ topic: 'Dev Team' })
if (!room) {
  console.warn('room invalid or not joined')
  return
}
await room.say('hi')
Defensive patterns

Strategy: fallback

Validate before calling

const room = await bot.Room.find(query)
if (!room || !room.isReady()) throw new Error('no valid room matched')

Type guard

function isValidRoom(room: RoomInterface | undefined): room is RoomInterface { return !!room && room.isReady() }

Try / catch

// returns undefined instead of throwing:
const room = await bot.Room.find(query)
if (!room) { /* refresh cache, re-search, or abort */ }

Prevention

When it happens

Trigger: Room.find(query) where roomSearch returns >= 1 rooms but every candidate fails `this.wechaty.puppet.roomValidate(room.id)`, typically because the cached room ids are stale, the bot was removed from the groups, or the puppet validation is buggy (see wechaty issue #1345).

Common situations: Bot was kicked out of or the group was dissolved after the payload was cached; puppet cache out of sync after reconnect; padchat-style puppets with known roomValidate issues; stale DB after long offline period.

Related errors


AI-assisted analysis of wechaty/wechaty@5a0520ac7d (2026-09-01). Data as JSON: /api/errors/df363cc5bd25c5ca. Report an issue: GitHub.