Downgrade getMetaInfo warning to debug for expected non-JSON responses - #129
Downgrade getMetaInfo warning to debug for expected non-JSON responses#129derekcentrico wants to merge 2 commits into
Conversation
WiiM devices return "Failed" or an empty body (HTTP 200) from the getMetaInfo endpoint when nothing is playing. Both trigger a JSONDecodeError, and session_call_api_json logs a WARNING for every occurrence. On a 5-second poll cycle this produces hundreds of warning lines per day in Home Assistant logs. The exception handler in bridge.py already treats "Failed" as a non-error, but it only ran after the warning was already logged. Empty responses were not handled at all and re-raised. Log at DEBUG instead of WARNING when the raw response is empty or "Failed". Broaden the bridge.py catch so empty responses are also treated as a silent non-error. Closes Velleman#128
Only suppress LinkPlayInvalidDataException when exc.data is an actual string whose stripped value is empty or "Failed". Exceptions raised without a data field (data=None) now re-raise instead of being silently swallowed.
|
Independent reproduction on a different device model, in case it helps with review. Device: WiiM Mini ( Confirmed the endpoint returns a bare 6-byte non-JSON body when idle ( Scale on a single idle device: 537,992 warnings over ~8 weeks (Jul 4 – Aug 30), which was 74% of all log entries on that instance. It buried several genuine faults — a dead sensor battery and an offline camera each went unnoticed for weeks because the log was unreadable. Worth emphasising that the device is entirely healthy: 15/15 requests answered in ~0.08 s across The One note for anyone landing here from search: this cannot be resolved by updating Home Assistant. Both 2026.7.0 and 2026.8.3 pin logger:
logs:
linkplay: error |
|
@Velleman Any chance you could take a look at this when you get a moment? We now have an independent reproduction from @firstofjuly on a different device model (WiiM Mini), logging over 500k warnings in 8 weeks from this single endpoint. The fix is minimal and scoped to the two known non-JSON responses ( |
Problem
WiiM devices return
"Failed"or an empty body (HTTP 200) from thegetMetaInfoendpoint when nothing is playing. Both triggerjson.JSONDecodeErrorinsession_call_api_json, which logs a WARNING before raisingLinkPlayInvalidDataException. On a 5-second poll cycle this produces hundreds of warning lines per day in Home Assistant logs:PR #93 added the
datafield to the exception and a catch inbridge.pyfordata == "Failed", but the warning was already emitted by that point. Empty-string responses were not handled at all and re-raised.Reported in #128 and in Home Assistant core issue #175775.
Fix
Two changes:
utils.py: Before logging, check whether the raw response is empty or
"Failed". Log at DEBUG for those cases, keep WARNING for truly unexpected payloads.bridge.py: Broaden the catch to also treat empty-string responses as a non-error (same as
"Failed"). Uses anisinstancecheck so exceptions raised without an explicitdatastring still re-raise correctly.Tests
Adds
test_meta_info_empty_response_handlingalongside the existingtest_meta_info_failed_handling. All 291 tests pass.Closes #128