Repository navigation
fix(claude-accounts): stop path resolution from creating the config directory - #12309
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Runtime path lookup remains side-effect free while credential materialization and keychain alias handling retain their required behavior. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…irectory getRuntimePaths() created ~/.claude as a side effect of resolving paths, so the deferred usage refresh materialized it even when Claude was disabled and no session had ever run. Writers already create the directory themselves (writeJson, writeRuntimeCredentials, the metadata dir), and the keychain helpers only use configDir as a service name, so resolution can stay pure. Fixes stablyai#12181
54a33fe to
ff83f4b
Compare
ELI5
Background Claude usage checks should read account paths without recreating directories. This removes the synchronous
mkdirSyncfrom path resolution; credential and configuration writers still create their own parent directories.What Changed
ClaudeRuntimePathResolver.getRuntimePaths()free of directory writes, including inheritedCLAUDE_CONFIG_DIRpaths.Why
A usage refresh reached the resolver even with Claude disabled and no managed account, repeatedly recreating
~/.claude. Each path lookup also paid for a redundant synchronous directory operation. The deterministic work-count regression exercises 1,000 lookups with both existing and missing directories: baseline performs 1,000mkdirSynccalls; this change performs zero. No timing or cache-freshness policy changes.Linked Issue
Fixes #12181.
Visual Proof
N/A — backend path resolution; no rendered or interaction changes.
Testing
Verified against
mainat1a9a5f9bc720, withORCA_BACKGROUND_LAUNCH=1, on macOS:pnpm test src/main/claude-accounts src/main/rate-limits: 692 tests passed in 71 files.pnpm tc:nodewith an 8 GB Node heap: passed.pnpm run check:code-quality:changed origin/main: passed all three changed-file gates.git diff --check: passed.The credential materialization test now starts without a runtime directory and removes the whole directory before a second launch. Both writes succeed and retain the expected credential contents. The existing broader suites cover account switching, readback, snapshots, file modes, and WSL selection. These local checks are not a claim of a full all-platform build/test run; PR CI covers the broader matrix.
Review
All current resolver consumers are in the Claude runtime auth service. Reads handle absent files; credential/config writers create parent directories themselves; Keychain calls use the config path as a namespace. Path construction still uses Node path APIs. Execution-host routing, SSH/WSL commands, folder-workspace behavior, remote wire formats, and refresh intervals are unchanged.
Original implementation by @makoto-developer; maintainer follow-up preserves the contributor commits, updates the branch to current main, and strengthens regression coverage.
AI Disclosure
The original PR disclosed Claude Code assistance. The maintainer follow-up and verification were assisted by OpenAI Codex.
Agent skill upstream boundary
Independent review follow-up
Preserve canonical macOS Keychain aliases when a missing config directory sits below a symlinked parent. Resolve the nearest existing ancestor without creating directories, and retain raw-only lookup for broken symlinks, inaccessible paths, or missing paths containing parent traversal (
..), whose canonical credential namespace cannot safely be inferred across symlinks. This fixes a rare credential-discovery regression while keeping redundant directory writes removed. Seven real-filesystem alias cases and the existing account suite pass (224 tests across 27 files); Node typecheck and changed-code quality pass. Keychain calls are mocked; no user credentials were accessed.