Skip to content

fix(terminal): strip provider env vars from background and PTY subprocesses#1172

Merged
teknium1 merged 3 commits intomainfrom
hermes/hermes-e0e71a89
Mar 13, 2026
Merged

fix(terminal): strip provider env vars from background and PTY subprocesses#1172
teknium1 merged 3 commits intomainfrom
hermes/hermes-e0e71a89

Conversation

@teknium1
Copy link
Contributor

Follow-up to PR #1157

PR #1157 fixed provider env var leakage in LocalEnvironment.execute() (foreground commands), but two paths in process_registry.py still leaked:

  • PTY spawn (line 156): pty_env = os.environ | (env_vars or {})
  • Background Popen (line 197): bg_env = os.environ | (env_vars or {})

This applies the same dynamic _HERMES_PROVIDER_ENV_BLOCKLIST from local.py to both paths. Explicit env_vars passed to spawn_local() still override the blocklist.

Gap identified by PR #1004 (@PeterFile).

All 37 tests pass (9 blocklist + 28 process registry).

Previously, when no watch_domains or watch_entities were configured,
ALL state_changed events passed through to the agent, causing users
to be flooded with notifications for every HA entity change.

Now events are dropped by default unless the user explicitly configures:
- watch_domains: list of domains to monitor (e.g. climate, light)
- watch_entities: list of specific entity IDs to monitor
- watch_all: true (new option — opt-in to receive all events)

A warning is logged at connect time if no filters are configured,
guiding users to set up their HA platform config.

All 49 gateway HA tests + 52 HA tool tests pass.
- homeassistant.md: Fix event filtering docs to reflect closed-by-default
  behavior. Add watch_all option. Replace Python dict config example with
  YAML. Fix defaults table (was incorrectly showing 'all'). Add required
  configuration warning admonition.
- environment-variables.md: Add HASS_TOKEN and HASS_URL to Messaging section.
- messaging/index.md: Add Home Assistant to description, architecture
  diagram, platform toolsets table, and Next Steps links.
…cesses

Extends the env var blocklist from #1157 to also cover the two remaining
leaky paths in process_registry.py:

- spawn_local() PTY path (line 156)
- spawn_local() background Popen path (line 197)

Both were still using raw os.environ, leaking provider vars to background
processes and interactive PTY sessions. Now uses the same dynamic
_HERMES_PROVIDER_ENV_BLOCKLIST from local.py.

Explicit env_vars passed to spawn_local() still override the blocklist,
matching the existing behavior for callers that intentionally need these.

Gap identified by PR #1004 (@PeterFile).
@teknium1 teknium1 merged commit 646b4ec into main Mar 13, 2026
1 check failed
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