Skip to content

fix(homeassistant): report webhook delivery failures - #60

Merged
pedropombeiro merged 1 commit into
mainfrom
fix/report-webhook-failures
Aug 19, 2026
Merged

pedropombeiro merged 1 commit into
mainfrom
fix/report-webhook-failures

Conversation

@pedropombeiro

Copy link
Copy Markdown
Owner

The log points away from the poll

que_01900ff31001wEwXwyDGJafjTv: poll started, entity=input_text.opencode_permission_response, timeout=120000ms
que_01900ff31001wEwXwyDGJafjTv: timed out after 120000ms (60 polls, 0 responses for other requests, 0 failed reads)

0 failed reads means the token and entity are fine — 60 successful reads. 0 responses for other requests means the helper held nothing for the full 120s. Combined with "nothing showed up on the phone", nobody ever wrote to it, because there was no notification to tap.

The poll is innocent. The remaining blind spot was delivery: sendWebhook had a per-URL .catch(() => {}), so a failed notification was indistinguishable from a delivered one.

Changes

Webhook failures now reach the log with URL and reason:

Cause Message
Wrong webhook id waiting webhook to https://ha…/webhook/typo failed: HTTP 404 (no notification was delivered)
Unauthorized … failed: HTTP 401 (no notification was delivered)
Slow HA … failed: timed out after 5000ms (no notification was delivered)
Unreachable … failed: Unable to connect. Is the computer able to access the url?
No URL for waiting no webhook URL configured for the waiting state, so no notification was sent

Each URL is reported separately, which matters for this exact topology: with waiting fanning out to a status URL and a notify URL, a healthy status webhook previously masked a failing notify webhook.

Timeout raised 2s → 5s. Two seconds is tight for a remote HA behind TLS, and a timeout meant a silently lost notification. The dispose drain grows 3s → 6s so it cannot truncate a request still inside its own timeout.

Verification

Real opencode process, waiting fanned out to a working status URL and a 404 notify URL — reproducing the reported signature:

HA:     08:24:24.588 STATUS webhook ok (waiting)
HA:     08:24:24.588 NOTIFY webhook -> 404 (automation id typo)
plugin: waiting webhook to http://127.0.0.1:8123/webhook/notify failed: HTTP 404 (no notification was delivered)
plugin: que_0191f1d0c001u5cXSwX0NRu8Hj: timed out after 20000ms (10 polls, 0 responses for other requests, 0 failed reads)

Same 0 failed reads / 0 responses timeout as the report, but the cause is now stated.

All six webhook failure modes covered in a unit harness. Existing receiver, negative-path, entity-read and config suites still pass. mise run typecheck, lint, build all pass.

What to check on the work laptop

Once this ships, the log will name the failing URL. Likely candidates: the opencode_work_agent_notify webhook id does not match the HA automation trigger, the notify automation is disabled, or delivery exceeded the old 2s timeout.

Webhook sends discarded every error, so a notification that never
arrived looked identical to one that did. The poll then ran normally and
timed out with zero failed reads, which pointed at the response helper
when the real fault was delivery.

Failures now reach the log with the URL and reason, covering non-2xx
statuses, timeouts and transport errors. Waiting-state failures add that
no notification was delivered, since that is the case where the agent
stays blocked with nothing on the phone. A waiting state with no
configured URL is reported too, rather than silently doing nothing.

Each URL is reported separately, so a working status webhook no longer
masks a failing notification webhook.

The per-request timeout moves from 2s to 5s. Two seconds is tight for a
remote Home Assistant behind TLS, and a timeout meant a silently lost
notification. The dispose drain grows to 6s so it cannot cut off a
request that is still within its own timeout.
@pedropombeiro
pedropombeiro merged commit ec59fec into main Aug 19, 2026
2 checks passed
@pedropombeiro
pedropombeiro deleted the fix/report-webhook-failures branch August 19, 2026 08:28
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