Repository navigation
fix(homeassistant): name the missing token variable - #56
Merged
Merged
Conversation
The work laptop reported only that the Home Assistant config was
unavailable, which lumped together three unrelated causes and left the
real one to guesswork.
When haToken uses ${ENV_VAR} expansion and the variable is missing from
the opencode process environment, the log now names that variable. A
token that only partly expands is also reported, since it would otherwise
be sent truncated and rejected by Home Assistant.
Documents that expansion reads the opencode process environment rather
than an interactive shell, that opencode does not read .env files, and
that a mise [env] entry does reach the process. Without this the failure
is invisible: the notification arrives and tapping it does nothing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause of the work-laptop failure
haTokenused${HA_OPENCODE_TOKEN}, and that variable was not in the opencode process environment.resolveHaConfig()returned undefined, so the poll never started. The notification arrived, tapping it did nothing, and the agent stayed blocked.Reproduced locally, including the 5s backstop clear that identified the plugin as never having consumed the helper:
The 0.7.2 tracing did its job — it pointed straight at the config — but its message lumped three unrelated causes into one line.
Changes
Name the exact missing variable instead of a generic "config unavailable":
haApiUrlabsenthaApiUrl is not sethaTokenabsenthaToken is not sethaToken references HA_OPENCODE_TOKEN, which is not set in the opencode process environmenthaToken resolved to an empty valueReport partial expansion.
${A}${B}with onlyBunset previously resolved non-empty, so the plugin silently sent a truncated token that Home Assistant would reject. That now reports…so the token is incompletewhile still attempting the poll.README documents that expansion reads the opencode process environment rather than an interactive shell, that opencode does not read
.envfiles, and that a mise[env]entry does reach the process.Verification
Two findings established by testing rather than assumption:
.env— a.envvar was invisible to a probe plugin while a shell-exported one was visible.[env]does reach opencode plugins — verified with the same probe.Also verified:
reply accepted (HTTP 200).mise run typecheck,lint,buildall pass.Note
The user's work machine is already fixed by configuration; no code change was required to unblock it. This PR is about making the next occurrence self-diagnosing.