Skip to content

fix(embedded): preserve shell environment variables when constructor defaults are empty - #3401

Open
handnewb wants to merge 2 commits into
vectorize-io:mainfrom
handnewb:fix/embedded-preserve-shell-env-vars
Open

fix(embedded): preserve shell environment variables when constructor defaults are empty#3401
handnewb wants to merge 2 commits into
vectorize-io:mainfrom
handnewb:fix/embedded-preserve-shell-env-vars

Conversation

@handnewb

Copy link
Copy Markdown
Contributor

Summary

Fixes #3253: HindsightEmbedded constructor included every parameter in the config dict even when the caller left them at their default of "". Those empty-string values travelled through the daemon-startup env pipeline and overwrote the caller's actual shell environment variables set via export or .env files.

Root Cause

The HINDSIGHT_* propagation loop in _start_daemon (line 543) used value is not None as its guard:

An empty string ("") is not None, so it was always propagated and overwrote any prior os.environ value. The caller's HINDSIGHT_API_LLM_API_KEY from their shell was silently replaced with "".

Changes (defence in depth)

1. embedded.py — source fix

New _set_if_truthy helper: only adds keys with truthy values to the config dict. An empty default no longer poisons the merged env. This is the primary fix — the constructor never emits empty values in the first place.

2. daemon_embed_manager.py — defense in depth

Guard propagation on value (truthy) instead of value is not None. Even if an empty string reaches this loop through some other path, it is harmlessly skipped.

Impact

Users can now set HINDSIGHT_API_LLM_API_KEY (and every other HINDSIGHT_* var) in their shell environment and have HindsightEmbedded() pick it up without explicitly passing it to the constructor.

@handnewb
handnewb force-pushed the fix/embedded-preserve-shell-env-vars branch from ae1bf8b to 8ce1df0 Compare August 11, 2026 21:24
…defaults are empty

The HindsightEmbedded constructor included every parameter in the config dict
even when the caller left them at their default of "".  Those empty-string
values travelled through the daemon-startup env pipeline and overwrote the
caller's actual shell environment variables (os.environ) set via export or
.env files, so HINDSIGHT_API_LLM_API_KEY (and every other key) was silently
ignored unless passed explicitly to the constructor.

Root cause: the HINDSIGHT_* propagation loop in _start_daemon used
'value is not None' as its guard, so an empty string was always propagated
and overwrote any prior os.environ value.

Changes (defence in depth):
- embedded.py: _set_if_truthy helper — only add keys with truthy values to
  the config dict.  An empty default no longer poisons the merged env.
- daemon_embed_manager.py: guard propagation on 'value' (truthy) instead of
  'value is not None', so even if an empty string reaches this loop it is
  harmlessly skipped.

Closes vectorize-io#3253.
@handnewb
handnewb force-pushed the fix/embedded-preserve-shell-env-vars branch from 8ce1df0 to 5da99b8 Compare August 11, 2026 21: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.

local_embedded: daemon ignores shell env — HINDSIGHT_API_LLM_API_KEY only works via config dict, error message is misleading

1 participant