Skip to content

fix: route push/pull through CLI when cloud storage env vars are set#2820

Merged
maphew merged 1 commit intosteveyegge:mainfrom
harry-miller-trimble:fix/dolt-start-env-passthrough
Mar 26, 2026
Merged

fix: route push/pull through CLI when cloud storage env vars are set#2820
maphew merged 1 commit intosteveyegge:mainfrom
harry-miller-trimble:fix/dolt-start-env-passthrough

Conversation

@harry-miller-trimble
Copy link
Copy Markdown
Contributor

Problem

When bd connects to an external dolt-sql-server (server mode), CALL DOLT_PUSH/DOLT_PULL executes inside the server process. That server only has env vars from when it was started. If cloud credentials (AZURE_STORAGE_ACCOUNT, AWS_ACCESS_KEY_ID, etc.) were set or changed after the server started, the SQL path silently fails to authenticate.

This breaks Azure Blob Storage, AWS S3, and GCS remotes when using bd dolt start (or auto-start) followed by bd dolt push/pull.

Fix

Add shouldUseCLIForCloudAuth() which detects cloud storage env var prefixes and routes through a CLI subprocess (dolt push/dolt pull) when in server mode. The subprocess inherits the current environment, ensuring credentials always reach the dolt process.

Cloud env prefixes detected:

  • AZURE_STORAGE_* — Azure Blob Storage
  • AWS_* — AWS S3
  • GOOGLE_* / GCS_* — Google Cloud Storage
  • OCI_* — Oracle Cloud Infrastructure
  • DOLT_REMOTE_* — Dolt-specific remote credentials

Applied to Push, ForcePush, and Pull methods in DoltStore.

Test Coverage

11 new test cases in credentials_test.go:

  • 8 positive: each cloud provider prefix triggers CLI routing
  • 3 negative: no env vars, embedded mode, no CLI remote

Backward Compatibility

  • No behavioral change when no cloud env vars are set (existing SQL path unchanged)
  • No behavioral change in embedded mode (env vars are in-process)
  • CLI routing only activates when: cloud env vars present + server mode + remote configured locally

Closes harry-miller-trimble#6

@harry-miller-trimble harry-miller-trimble force-pushed the fix/dolt-start-env-passthrough branch from f92a7d1 to 56ac1e0 Compare March 25, 2026 04:08
When bd connects to an external dolt-sql-server (server mode), CALL
DOLT_PUSH/PULL executes inside the server process. That process only has
the env vars it inherited at startup. If cloud credentials (AZURE_*,
AWS_*, GOOGLE_*, etc.) were set or changed after the server started, the
SQL path silently fails to authenticate.

Add shouldUseCLIForCloudAuth() which detects cloud storage env var
prefixes and routes through a CLI subprocess (dolt push/pull) when in
server mode. The subprocess inherits the current environment, ensuring
credentials always reach the dolt process.

Applied to Push, ForcePush, and Pull methods.

Closes #6

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@harry-miller-trimble harry-miller-trimble force-pushed the fix/dolt-start-env-passthrough branch from 56ac1e0 to 6e8a7dc Compare March 25, 2026 04:09
@maphew
Copy link
Copy Markdown
Collaborator

maphew commented Mar 26, 2026

Thanks @harry-miller-trimble — solid fix for a subtle issue. The CLI fallback when cloud creds are set after server start is a good approach, and the test coverage is thorough.

@maphew maphew merged commit 1c93599 into steveyegge:main Mar 26, 2026
19 checks passed
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.

bd dolt start strips environment variables from child dolt process

2 participants