Matter accessory string length errors surface as opaque Matter.js validation failures
Analysis
Matter accessory string length errors surface as opaque Matter.js validation failures
Description
When a plugin registers a Matter accessory with a Basic Information string that exceeds the Matter-defined maximum length, registerPlatformAccessories() eventually fails with a low-level Matter.js validation error rather than identifying the invalid MatterAccessory property.
For example, registering an accessory with a model value longer than 35 characters results in an error referring to productName and the Matter constraint (135).
Similarly, an overlength manufacturer results in an error referring to the Matter vendorName attribute.
This makes the source of the problem difficult for a Homebridge plugin developer to identify because the property names exposed by the Homebridge MatterAccessory API differ from those reported by the underlying Matter.js validation.
Example
A plugin creates a Matter accessory containing:
const accessory: MatterAccessory = {
UUID: uuid,
displayName: 'Matter Switch',
deviceType: api.matter.deviceTypes.OnOffSwitch,
serialNumber: '1234567',
manufacturer: 'Virtual Matter Accessories',
model: 'Virtual Accessory - OnOffLightSwitch',
context: {},
};The model value:
Virtual Accessory - OnOffLightSwitchis 36 characters long.
The corresponding Matter field has a maximum length of 35 characters.
Registration subsequently fails inside the Matter stack with an error referring to productName and the constraint:
(135)Reducing the value to 35 characters or fewer allows registration to proceed.
The same class of failure can be reproduced with an overlength manufacturer, where the resulting Matter error refers to vendorName.
Expected behavior
Ideally, the Homebridge Matter API should validate the constraints applicable to MatterAccessory properties before constructing/registering the underlying Matter endpoint.
For example, an invalid model could produce an error similar to:
Matter accessory "Matter Switch": model cannot exceed 35 charactersand an invalid manufacturer:
Matter accessory "Matter Switch": manufacturer cannot exceed 35 charactersAt minimum, the documented MatterAccessory API should expose the applicable length constraints so plugin developers can validate these fields before calling registerPlatformAccessories().
Actual behavior
The Homebridge API accepts the MatterAccessory object and the invalid value propagates into Matter.js.
Validation then occurs against the underlying Matter attribute, producing an error using Matter terminology such as productName or vendorName rather than the corresponding Homebridge MatterAccessory property.
As a result, it is not immediately apparent that a plugin's model or manufacturer string is responsible for the registration failure.
Why this is difficult to diagnose
The Homebridge API exposes properties such as:
manufacturer
model
serialNumberwhile the eventual validation failure is produced against the corresponding Matter Basic Information attributes.
A plugin author therefore has to determine:
Homebridge MatterAccessory.model
↓
Matter Basic Information productName
↓
Matter.js constraint failurebefore discovering that the original problem is simply a string exceeding the Matter length limit.
Possible API improvement: constructible MatterAccessory
One possible way to address this more generally would be for Homebridge to provide a constructible Matter accessory type rather than exposing MatterAccessory only as an interface that plugins populate directly.
For example, conceptually:
const accessory = new MatterAccessory(
displayName,
uuid,
deviceType,
);or a Matter equivalent of the existing PlatformAccessory abstraction.
Construction would provide Homebridge with a natural API boundary at which to validate Matter requirements before an accessory reaches Matter.js. Properties such as displayName, serialNumber, manufacturer, and model could then be validated when they are initially supplied and, if mutable, whenever they are subsequently changed.
This would allow errors to be reported using the Homebridge API property names that plugin developers are working with rather than the corresponding lower-level Matter attribute names.
It could also centralize other MatterAccessory invariants as the Matter plugin API evolves, instead of requiring every plugin to independently know and reproduce Matter-specific constraints.
Currently a plugin can create a structurally valid TypeScript MatterAccessory object containing values that are not valid Matter values:
const accessory: MatterAccessory = {
// TypeScript-valid, but potentially Matter-invalid values
};The problem is therefore discovered only later during endpoint construction/registration.
A constructible accessory abstraction would make the Homebridge Matter API more similar to the HAP plugin API, where PlatformAccessory represents an actual Homebridge-managed accessory object rather than just the shape of an object supplied by a plugin.
Additional information
As a workaround, a plugin can introduce its own wrapper around MatterAccessory and perform validation there. For example:
if (model.length > 35) {
throw new RangeError('model cannot exceed 35 characters');
}This produces a substantially more actionable error than allowing the invalid value to reach Matter.js.
It would be useful if this validation were performed by Homebridge itself, either during construction of a Homebridge-provided Matter accessory abstraction or at the registerPlatformAccessories() API boundary.
Expected Behavior
N/A
Steps To Reproduce
N/A
Logs
N/AConfiguration
N/AEnvironment
OS: macOS 26.5.1 Homebridge: v2.4.1-beta.11 Homebridge UI: v5.29.1-beta.1 Node: v24.11.0
Process Supervisor
hb-service
Additional Context
No response
Source: homebridge/homebridge