{"record":{"id":"df363cc5bd25c5ca","repo":"wechaty/wechaty","slug":"find-all-d-rooms-are-invalid","errorCode":null,"errorMessage":"find() all %d rooms are invalid","messagePattern":"find\\(\\) all (.+?) rooms are invalid","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/user-modules/room.ts","lineNumber":241,"sourceCode":"    }\n\n    if (roomList.length > 1) {\n      log.warn('Room', 'find() got more than one(%d) result', roomList.length)\n    }\n\n    for (const [ idx, room ] of roomList.entries()) {\n      // use puppet.roomValidate() to confirm double confirm that this roomId is valid.\n      // https://github.com/wechaty/wechaty-puppet-padchat/issues/64\n      // https://github.com/wechaty/wechaty/issues/1345\n      const valid = await this.wechaty.puppet.roomValidate(room.id)\n      if (valid) {\n        log.verbose('Room', 'find() room<id=%s> is valid: return it', idx, room.id)\n        return room\n      } else {\n        log.verbose('Room', 'find() room<id=%s> is invalid: skip it', idx, room.id)\n      }\n    }\n    log.warn('Room', 'find() all %d rooms are invalid', roomList.length)\n    return undefined\n  }\n\n  /**      const roomList: RoomInterface[] = []\n\n   * @ignore\n   *\n   * Instance Properties\n   *\n   *\n   */\n  payload?: PUPPET.payloads.Room\n\n  /**\n   * @hideconstructor\n   * @property {string}  id - Room id.\n   * This function is depending on the Puppet Implementation, see [puppet-compatible-table](https://github.com/wechaty/wechaty/wiki/Puppet#3-puppet-compatible-table)\n   */","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/wechaty/wechaty/blob/5a0520ac7d0567777d6931eee53f81bbfcae1453/src/user-modules/room.ts#L223-L259","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Clear the puppet's room cache / restart the bot so payloads are refreshed","Verify with room.say()-free checks like room.sync() or re-searching by id","Confirm the bot is still a member of the target group","Update/switch the puppet implementation if roomValidate is known-buggy"],"exampleFix":"// before\nconst room = await bot.Room.find({ topic: 'Dev Team' })\nawait room.say('hi') // room may be undefined\n// after\nconst room = await bot.Room.find({ topic: 'Dev Team' })\nif (!room) {\n  console.warn('room invalid or not joined')\n  return\n}\nawait room.say('hi')","handlingStrategy":"fallback","validationCode":"const room = await bot.Room.find(query)\nif (!room || !room.isReady()) throw new Error('no valid room matched')","typeGuard":"function isValidRoom(room: RoomInterface | undefined): room is RoomInterface { return !!room && room.isReady() }","tryCatchPattern":"// returns undefined instead of throwing:\nconst room = await bot.Room.find(query)\nif (!room) { /* refresh cache, re-search, or abort */ }","preventionTips":["Handle the undefined return of Room.find()","Restart/refresh the puppet cache after long offline periods","Confirm bot membership in target groups","Keep puppet implementations updated"],"tags":["room","stale-cache","validation-failed"],"backgroundTag":"room-validation-failed","analyzedSha":"5a0520ac7d0567777d6931eee53f81bbfcae1453","analyzedAt":"2026-09-01T01:57:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}