Skip to content

fix(secrets-store): mkdir parent dir before NamedTemporaryFile (Windows compat)#438

Merged
0xmariowu merged 2 commits intomainfrom
fix/windows-secrets-mkdir-parent
Apr 26, 2026
Merged

fix(secrets-store): mkdir parent dir before NamedTemporaryFile (Windows compat)#438
0xmariowu merged 2 commits intomainfrom
fix/windows-secrets-mkdir-parent

Conversation

@0xmariowu
Copy link
Copy Markdown
Owner

Summary

Fixes the Windows-only Cross-Platform Tests regression on main introduced by F007 (#431) secrets_store.write_secret(...).

Root cause

write_secret uses tempfile.NamedTemporaryFile(dir=path.parent, delete=False). On Linux this succeeds even when path.parent is missing; on Windows it raises FileNotFoundError immediately. The CLI smoke test (test_cli_configure_inline_value_works_non_interactively) passes a path under a tmp dir that doesn't have .config/ created yet — fail on Windows, pass on Linux.

Fix

autosearch/core/secrets_store.py write_secret(...): ensure path.parent exists via mkdir(parents=True, exist_ok=True) before opening the temp file. New unit test test_write_secret_creates_parent_dir locks the contract.

Test plan

  • pytest tests/unit/test_secrets_store.py tests/smoke/test_cli_configure_smoke.py — 26 passed
  • pytest tests/unit/ -m "not real_llm and not slow and not network" — 711 passed, 3 skipped
  • ruff clean

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 26, 2026 14:05
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 26, 2026

Warning

Rate limit exceeded

@0xmariowu has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 45 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 5 minutes and 45 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b9082946-3365-45cb-bb41-81893ba28c22

📥 Commits

Reviewing files that changed from the base of the PR and between df6c39c and 81ed85d.

📒 Files selected for processing (2)
  • autosearch/core/secrets_store.py
  • tests/unit/test_secrets_store.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts write_secret(...) behavior and adds a unit test intended to prevent Windows failures when writing secrets to a nested (non-existent) directory path.

Changes:

  • Adds a unit test asserting write_secret(...) creates missing parent directories for the target secrets file.
  • Adds an extra mkdir(parents=True, exist_ok=True) call for the lock file’s parent directory in write_secret(...).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
autosearch/core/secrets_store.py Adds an additional parent-directory mkdir for the lock file path in write_secret(...).
tests/unit/test_secrets_store.py Adds a test that writes to a nested path and asserts the file is created with expected contents.

Comment thread autosearch/core/secrets_store.py
Comment thread autosearch/core/secrets_store.py
@0xmariowu 0xmariowu merged commit acf3408 into main Apr 26, 2026
14 checks passed
@0xmariowu 0xmariowu deleted the fix/windows-secrets-mkdir-parent branch April 26, 2026 14:10
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.

2 participants