Skip to content

fix: tolerate empty optional endpoints on factory-reset ISY-994#506

Merged
shbatm merged 1 commit into
v3.x.xfrom
fix/empty-optional-endpoints-no-error-spam
May 8, 2026
Merged

fix: tolerate empty optional endpoints on factory-reset ISY-994#506
shbatm merged 1 commit into
v3.x.xfrom
fix/empty-optional-endpoints-no-error-spam

Conversation

@shbatm
Copy link
Copy Markdown
Collaborator

@shbatm shbatm commented May 8, 2026

Summary

A factory-reset ISY-994 has no variables and no networking resources configured. Its REST API returns 404 for /rest/vars/definitions/{1,2} and /rest/networking/resources — and on top of that its keep-alive framing desyncs after a 404, so the next request on the reused socket parses as a 400 Expected HTTP/, RTSP/ or ICE/: error containing the prior 404's HTML body.

PyISY handled all of this functionally (the variable parser already tolerated the 404 body strings via EMPTY_VARIABLE_RESPONSES, the network manager handled None), but every initialize() against an empty controller emitted three ERROR-level log lines + one 400 traceback for what is really an empty-config success.

What changed

  • get_variable_defs() now passes ok404=True per request so the per-type 404 returns benign "" instead of an ERROR Invalid Command Received log line.
  • Variables.parse_definitions() now treats "" the same as None ("no variables defined"), matching the existing EMPTY_VARIABLE_RESPONSES handling.
  • Connection.request() treats aiohttp.ClientResponseError as benign when the caller already opted into ok404=True. The ISY-994 keep-alive desync after a 404 surfaces as a parser error, but the caller already said "this endpoint may legitimately be empty" — so we absorb it the same way.

Before / after (factory-reset ISY-994 at TLS 1.1, HTTP)

Before:

ERROR ISY Reported an Invalid Command Received /vars/definitions/1
ERROR Client Response Error from ISY: 400 Expected HTTP/, RTSP/ or ICE/:
  <HTML>...<BODY>/CONF/NET/RES.CFG not found</BODY></HTML>
ERROR Client Response Error from ISY: 400 Expected HTTP/, RTSP/ or ICE/:
  <HTML>...<BODY>/CONF/STATE.VAR not found</BODY></HTML>

After:

INFO No Type 1 variables defined
INFO No Type 2 variables defined
WARNING No valid variables defined

(plus one DEBUG line per absorbed framing error.)

Test plan

  • pytest -q (438 passed)
  • Pre-commit clean
  • Smoke-tested against a factory-reset ISY-994: previously 3 ERRORs and a 400 traceback during initialize(); now only the existing INFO/WARNING signals
  • New regression tests:
    • test_get_variable_defs_passes_ok404
    • test_request_client_response_error_with_ok404_returns_empty

🤖 Generated with Claude Code

A factory-reset ISY-994 has no variables and no networking resources
configured, so its REST API returns 404 for /rest/vars/definitions/{1,2}
and /rest/networking/resources. The package handled this functionally
(empty managers, the variable parser already recognizes the 404 body
strings) but emitted ERROR-level log noise on every initialize().

Two paths cleaned up:

- get_variable_defs() now passes ok404=True per request, so the per-type
  404s come back as benign "" instead of an ERROR "Invalid Command
  Received" log line. The Variables parser already tolerated this body
  via EMPTY_VARIABLE_RESPONSES; tightened it to also treat "" the same
  as None ("no variables defined").

- Connection.request() now treats aiohttp.ClientResponseError as benign
  when the caller already opted into ok404=True. ISY-994 firmware
  desyncs keep-alive after a 404 for missing optional resources — the
  next request on the reused socket reads the prior 404's HTML body
  where an HTTP status line should be, surfacing as a "400 Expected
  HTTP/, RTSP/ or ICE/:" parser error. The opt-in already says "this
  endpoint may legitimately be empty", so absorb the 400-reframing the
  same way.

Smoke-tested against a factory-reset ISY-994: previously emitted three
ERROR lines and one 400 traceback during initialize(); now emits only
the existing INFO ("No Type N variables defined") and WARNING ("No
valid variables defined") signals.
@shbatm shbatm merged commit 64349f1 into v3.x.x May 8, 2026
4 checks passed
@shbatm shbatm deleted the fix/empty-optional-endpoints-no-error-spam branch May 8, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant