Skip to content

Load shell credentials through Python - #283

Merged
Eli Pinkerton (wallstop) merged 1 commit into
mainfrom
migrate/sourced-env-python
Oct 18, 2026
Merged

Eli Pinkerton (wallstop) merged 1 commit into
mainfrom
migrate/sourced-env-python

Conversation

@wallstop

@wallstop Eli Pinkerton (wallstop) commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

DISCLOSURE: LLM-GENERATED TEXT

Why: Interactive shells duplicate the environment parser in Bash.

What:

  • Parse shell credentials with the shared typed Python loader through uv.
  • Preserve literal values, file selection, and shell variable precedence.
  • Apply exports only after parsing succeeds.
  • Check loader failures and compatibility cases explicitly.

Refs #171.


Note

Medium Risk
Changes how MCP credentials and other env vars are loaded in every interactive shell; mistakes could break agent CLIs or credential rotation without a rebuild, though behavior is heavily contract-tested.

Overview
Replaces inline Bash parsing of .env.local with the shared Python loader invoked via uv run, so interactive shells use the same precedence and literal-value rules as load_environment in Python startup paths (issue #171).

load_env_local in env-local.sh now streams NUL-delimited key/value/overwrite records from env_local.py, skips exports when a non-empty shell value should win (including unexported locals the child cannot see), and applies all exports only after a successful parse—failures return 1 with no partial updates. env_local.py gains loaded_assignments and a small CLI main() that builds the full payload before writing (no shell injection from command substitutions in values).

Tests pin DATAVIZ_ENV_UV, treat loader failures explicitly, and add shell-adapter cases for literals, atomic failure on bad input/missing uv, file path selection, and MCP credential rotation under DATAVIZ_ENV_LOCAL_PRECEDENCE=file.

Reviewed by Cursor Bugbot for commit 4c13bc8. Bugbot is set up for automated code reviews on this repo. Configure here.

Interactive shells still duplicate the environment parser in Bash. Use the shared typed Python parser through uv and keep a small adapter for parent-shell exports.

Preserve literal values, file selection, duplicate keys, credential precedence, and unexported shell values. Buffer exports until parsing completes. Make loader failure assertions explicit.

Validation: strict pyright passes for both Python files. All 42 harness suites and check:gate pass; npm pack dry run passes. Unity 6000.5.2f1 on Windows passes 393 EditMode and 15 PlayMode tests. The config generator and HTTP bridge remain in Node. Refs #171.
@wallstop
Eli Pinkerton (wallstop) added this pull request to stack #291 October 18, 2026 05:59
@wallstop
Eli Pinkerton (wallstop) merged commit 5c1b4de into main Oct 18, 2026
3 checks passed
@wallstop
Eli Pinkerton (wallstop) deleted the migrate/sourced-env-python branch October 18, 2026 06:09
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