Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty groups.yml: "TypeError: Cannot convert undefined or null to object" during interviewing #20283

Closed
rhuss opened this issue Dec 18, 2023 · 4 comments
Labels
problem Something isn't working

Comments

@rhuss
Copy link
Contributor

rhuss commented Dec 18, 2023

What happened?

When trying to pair a Aqara RTCGQ11LM motion sensor I get the following error when trying to pair:

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at /app/lib/util/settings.ts:241:50
    at Array.map (<anonymous>)
    at writeDevicesOrGroups (/app/lib/util/settings.ts:241:22)
    at write (/app/lib/util/settings.ts:251:5)
    at Object.addDevice (/app/lib/util/settings.ts:560:5)
    at Device.ensureInSettings (/app/lib/model/device.ts:42:22)
    at Zigbee.resolveDevice (/app/lib/zigbee.ts:247:20)
    at Controller.<anonymous> (/app/lib/zigbee.ts:91:33)
    at Controller.emit (node:events:517:28)

After that the server stops. After restart I see the following in the logs

Zigbee2MQTT:info  2023-12-18 21:25:05: 0x00158d000a832619 (0x00158d000a832619): Not supported (Unknown)
....
Zigbee2MQTT:warn  2023-12-18 21:28:20: Received message from unsupported device with Zigbee model 'undefined' and manufacturer name 'undefined'
Zigbee2MQTT:warn  2023-12-18 21:28:20: Please see: https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html

What did you expect to happen?

I expect that pairing either works without problem or a clear error message appears, without crashing the server.

How to reproduce it (minimal and precise)

Just pair an Aqara RTCGQ11LM

Zigbee2MQTT version

1.34.0-dev (commit #29635a9)

Adapter firmware version

20230507

Adapter

Slaesh's CC2652

Debug log

No extra logs except that stacktrace pasted above.

@rhuss rhuss added the problem Something isn't working label Dec 18, 2023
@rhuss
Copy link
Contributor Author

rhuss commented Dec 18, 2023

Side note: I'm using multiple device.yml files, one for read-write and the others read-only (they are served from a ConfigMap in Kubernetes). My configuration looks like:

# Use different files for devices and groups
# Comment out the next line temporarily on rw errors:
devices:
  - devices-run.yaml
  - devices.yaml
#devices: devices.yaml
groups:
  - groups-run.yaml
  - groups.yaml

@rhuss
Copy link
Contributor Author

rhuss commented Dec 18, 2023

devices-run.yaml contains a YAML map, groups-run.yaml contains an empty map ({})

@rhuss rhuss changed the title "TypeError: Cannot convert undefined or null to object" during interviewing Empty groups.yml: "TypeError: Cannot convert undefined or null to object" during interviewing Dec 18, 2023
@rhuss
Copy link
Contributor Author

rhuss commented Dec 18, 2023

It turned out, that groups.yaml contained only comments, so that yaml.load(...) probably returned null. That then caused that exception.

If I add an empty {} to the groups.yaml, everything's fine. Maybe one can make that a bit more robust ?

rhuss added a commit to rhuss/zigbee2mqtt that referenced this issue Dec 19, 2023
Koenkk pushed a commit that referenced this issue Dec 20, 2023
* Always return an object when loading a YAML file, even when it is empty or containing the `null` value.

Fixes #20283

* Add unit test for having multiple device files, with one is empty. This test breaks without the proposed.
@rhuss
Copy link
Contributor Author

rhuss commented Dec 21, 2023

Fixed with #20289

@rhuss rhuss closed this as completed Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant