{"record":{"id":"20b4190d812766f0","repo":"homebridge/homebridge","slug":"pluginidentifier-all-accessories-length-mat","errorCode":null,"errorMessage":"${pluginIdentifier}: All ${accessories.length} Matter accessories failed validation","messagePattern":"(.+?): All (.+?) Matter accessories failed validation","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/matter/MatterAPIImpl.ts","lineNumber":297,"sourceCode":"    platformName: PlatformName,\n    accessories: MatterAccessory[],\n  ): Promise<void> {\n    if (accessories.length === 0) {\n      log.warn(`${pluginIdentifier}: Attempted to register 0 Matter accessories`)\n      return\n    }\n\n    this.assertMatterReady(`${pluginIdentifier}: Cannot register Matter accessories`)\n\n    // Validate all accessories before registration\n    const validAccessories = this.validateAccessories(\n      accessories,\n      `registerPlatformAccessories (${pluginIdentifier}/${platformName})`,\n    )\n\n    if (validAccessories.length === 0) {\n      log.error(`${pluginIdentifier}: All ${accessories.length} Matter accessories failed validation`)\n      return\n    }\n\n    if (validAccessories.length < accessories.length) {\n      log.warn(\n        `${pluginIdentifier}: ${accessories.length - validAccessories.length} of ${accessories.length} Matter accessories failed validation`,\n      )\n    }\n\n    // Split accessories into normal (bridge) and external (standalone) based on device type\n    const normalAccessories: MatterAccessory[] = []\n    const externalAccessories: MatterAccessory[] = []\n\n    for (const accessory of validAccessories) {\n      if (requiresExternalBridge(accessory.deviceType)) {\n        externalAccessories.push(accessory)\n      } else {\n        normalAccessories.push(accessory)\n      }","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/homebridge/homebridge/blob/edf54930340d67cade23d01abd41b03cd9621e8b/src/matter/MatterAPIImpl.ts#L279-L315","documentation":"registerPlatformAccessories in MatterAPIImpl logs an error and returns when every accessory in the call failed validateMatterAccessory (validAccessories.length === 0). Nothing is registered. All passed objects were structurally invalid, not just one — typically missing UUID, displayName, or a valid Matter device type.","triggerScenarios":"1) Plugin passes plain objects missing required MatterAccessory fields. 2) HAP-style PlatformAccessory objects passed to the Matter API. 3) Device-type helpers misused so deviceType is undefined for all accessories.","commonSituations":"Plugins ported from HAP code paths; custom device objects missing required metadata; api.matter.switch.* helpers used incorrectly.","solutions":["Read the validator's per-accessory logs to see which required fields are missing.","Construct accessories with the documented MatterAccessory shape and a device type helper (e.g. api.matter.switch.*).","Pass MatterAccessory objects, not HAP PlatformAccessory objects.","Align plugin and Homebridge versions so device-type helpers exist."],"exampleFix":"// before\nconst accs = devices.map(d => ({ name: d.name }))\napi.matter.registerPlatformAccessories(plugin, platform, accs)\n// after\nconst accs = devices.map(d => ({\n  UUID: hap.uuid.generate(d.id),\n  displayName: d.name,\n  ...api.matter.switch.createSwitchDevice(),\n}))\napi.matter.registerPlatformAccessories(plugin, platform, accs)","handlingStrategy":"type-guard","validationCode":"function isWellFormedAccessory(a: unknown): boolean {\n  const x = a as Partial<MatterAccessory>\n  return typeof x.UUID === 'string' && typeof x.displayName === 'string' && x.device !== undefined\n}\nconst accs = devices.map(toMatterAccessory).filter(isWellFormedAccessory)","typeGuard":"function isMatterAccessory(a: unknown): a is MatterAccessory {\n  return (\n    typeof a === 'object' && a !== null &&\n    typeof (a as any).UUID === 'string' &&\n    typeof (a as any).displayName === 'string' &&\n    (a as any).device !== undefined\n  )\n}","tryCatchPattern":"try {\n  await api.matter.registerPlatformAccessories(plugin, platform, accs)\n} catch (err) {\n  log.error('Matter registration failed', err)\n}","preventionTips":["Build accessories through the official api.matter device-type helpers.","Never pass HAP PlatformAccessory objects to the Matter API.","Validate accessory shape in plugin unit tests.","Read per-accessory validation logs to fix the failing fields."],"tags":["matter","validation","accessory-schema","plugin-api"],"backgroundTag":"accessory-validation-failed","analyzedSha":"edf54930340d67cade23d01abd41b03cd9621e8b","analyzedAt":"2026-08-30T21:28:53.235Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}