Skip to content

fix(python): preserve credential placeholder env on snapshot restore#1605

Merged
chaliy merged 1 commit intomainfrom
2026-05-08-propose-fix-for-credential-placeholder-issue
May 8, 2026
Merged

fix(python): preserve credential placeholder env on snapshot restore#1605
chaliy merged 1 commit intomainfrom
2026-05-08-propose-fix-for-credential-placeholder-issue

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented May 8, 2026

Motivation

  • Snapshot restore was overwriting freshly generated credential-placeholder env vars installed by credential_placeholder(...), causing script-visible placeholders to be stale or absent while HTTP hooks expected newly generated tokens.
  • This broke authenticated requests after from_snapshot()/restore_snapshot() flows without exposing the real credential, so restored instances could silently fail network auth.

Description

  • Capture live placeholder env values before restoring snapshot and re-apply them after the snapshot state is loaded by adding restore_live_bash_with_env_overrides and placeholder_env_overrides helper functions in crates/bashkit-python/src/lib.rs.
  • Update PyBash::restore_snapshot and BashTool::restore_snapshot to collect placeholder env overrides and call the new restore helper so placeholders remain aligned with active HTTP credential hooks.
  • Add a regression test test_bashtool_from_snapshot_reapplies_placeholder_env_after_restore in crates/bashkit-python/tests/test_network_credentials.py to assert that a placeholder env is present after BashTool.from_snapshot() when the source snapshot lacks placeholder env state.

Testing

  • Ran cargo fmt --all, which completed successfully.
  • Ran python -m pytest crates/bashkit-python/tests/test_network_credentials.py -k from_snapshot which failed in this environment with ModuleNotFoundError: No module named 'bashkit' during test collection so the Python-level test could not be executed here.
  • Invoked cargo test -p bashkit-python --no-run which began dependency resolution and compilation but could not complete within the validation window (network/dependency fetch in progress), so no final pass/fail was recorded.

Codex Task

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 8, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 89e35b6 Commit Preview URL May 08 2026, 09:15 AM

@chaliy chaliy force-pushed the 2026-05-08-propose-fix-for-credential-placeholder-issue branch from 0ce260b to 1a22560 Compare May 8, 2026 09:10
@chaliy chaliy force-pushed the 2026-05-08-propose-fix-for-credential-placeholder-issue branch from 1a22560 to 89e35b6 Compare May 8, 2026 09:14
@chaliy chaliy merged commit 6931716 into main May 8, 2026
24 checks passed
@chaliy chaliy deleted the 2026-05-08-propose-fix-for-credential-placeholder-issue branch May 8, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant