Skip to content

fix(config): keep credential storage independent of working directories - #158

Merged
francoischalifour merged 8 commits into
mainfrom
fc/safe-user-directories-review
Oct 19, 2026
Merged

francoischalifour merged 8 commits into
mainfrom
fc/safe-user-directories-review

Conversation

@francoischalifour

@francoischalifour francoischalifour commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

When HOME is unset, the CLI can save profiles and credentials under the current project instead of the user's home directory. This fixes directory resolution through a shared API used by configuration storage and shell-completion installation.

Use os.homedir() directly for platform-native home resolution, preserve the existing config-directory precedence and layout, and reject relative or Windows current-drive-dependent directory settings before accessing storage. Credentials accidentally written inside projects are not imported automatically; affected users should sign in again and revoke any exposed credentials.

Windows CI also exposed credential configuration exiting before its asynchronous stdin read completed, with no credentials saved. Read credential stdin through the standard file-descriptor API before continuing; regressions cover both API keys and lakehouse passwords, with pipe and file input.

The Windows file backend stops interpreting Unix mode bits as ACL permissions. This is an interim compatibility correction: the file fallback remains plaintext, Windows ACLs are not validated, and native credential-manager integration is a separate workstream. #151 remains open for that work.

Verification passed on commit 62534ec: canonical repository/integration checks, public CLI regressions against source and npm bundles on Linux/macOS/Windows, minimum supported Bun runtime, and compiled-binary builds/smoke tests for all release targets. The regression coverage includes directory precedence, invalid paths, credential reads across working directories, completion installation, and Windows USERPROFILE precedence.

Fixes #150.
Related to #151.

Exercise credential storage across directories and reject relative user-directory settings through CLI commands. Cover missing HOME through the public config API without touching the actual user configuration.
Use the OS home directory when HOME is absent and share absolute-path validation across profile storage and shell completion. Preserve directory precedence and the existing layout without importing project-local credentials.

Apply POSIX credential mode checks only on platforms where they describe access permissions. State the Windows ACL limitation explicitly and exercise source and npm bundle storage behavior in cross-platform CI.
const home = readEnv("HOME");
if (home) return requireAbsoluteDirectory(home, "HOME");
try {
return requireAbsoluteDirectory(homedir(), "OS home directory");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably default to this instead of the env var?

Comment thread cli/src/lib/secrets.ts
}

function requireSafeCredentialsFile(): void {
function requireSafeCredentialsFile(platform: NodeJS.Platform): void {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we want to support Windows we should use a dedicated secret-store abstraction (https://github.com/Brooooooklyn/keyring-node or the like) to actually use Windows' credential manager

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed—native credential storage is the direction we should take. The permission-check change here only unblocks the existing file backend. It doesn’t add native protection.

I'll leave #151 open for now.

Use os.homedir directly so Windows follows USERPROFILE instead of a separate HOME override. Retain absolute-path validation and explicit config overrides.

Exercise completion installation in isolated CLI processes because Bun caches its home-directory lookup. Cover Windows HOME and USERPROFILE precedence through the public CLI.

@albert20260301 albert20260301 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The required Windows User directories job is failing at Verify user-directory storage through CLI commands, so this cannot merge yet. Please fix the Windows regression and rerun the cross-platform storage gate; Linux and macOS passing is not sufficient for this credential-path remediation.

Pass credential input directly to Bun.spawn instead of manually closing a pipe before the child consumes it. Keep the storage regressions focused on completed CLI invocations across platforms.
Windows CI reproduces early child exit while credential stdin is supplied through a pipe, including Bun.spawn Blob input. Use a temporary input file so directory tests exercise completed public CLI writes without depending on pipe lifetime.
Windows CI reproduces successful process exit with no saved credentials while awaiting Bun.stdin.text, for both pipe and file-backed input. Read file descriptor zero synchronously so configure completes before the process can exit.

Cover API keys and lakehouse passwords through public CLI subprocesses while preserving directory and secret-storage assertions.
@francoischalifour
francoischalifour merged commit 4902463 into main Oct 19, 2026
16 checks passed
@francoischalifour
francoischalifour deleted the fc/safe-user-directories-review branch October 19, 2026 11:49
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.

Windows/PowerShell: config and credentials are written to the current directory when HOME is unset

4 participants