Skip to content

fix: close open file handles in expert_vault.py (#25) - #30

Open
HeaTTap wants to merge 1 commit into
CyberSunil:mainfrom
HeaTTap:fix-expert-vault-open-file-handles
Open

HeaTTap wants to merge 1 commit into
CyberSunil:mainfrom
HeaTTap:fix-expert-vault-open-file-handles

Conversation

@HeaTTap

@HeaTTap HeaTTap commented Sep 17, 2026

Copy link
Copy Markdown

closes #25

wraps file open calls in expert_vault.py inside with blocks to ensure file handles are properly closed on exit or on decryption errors

changes:

  • updated try_unlock to use with blocks when reading expert_meta.json and expert.enc
  • updated expert_count to use with block when reading expert_meta.json
  • added unit tests in tests/test_expert_vault.py covering file handle closure, missing files, and unlock lifecycle

testing:

  • pytest -q passed all 32 tests
  • ruff check passed

@CyberSunil

Copy link
Copy Markdown
Owner

Thanks for this, and for the tests! The with-block cleanup is a good idea. The problem is this branch was created before #3 was merged, so right now it would revert the integrity-check work from #3 (it removes EXPECTED_ENC_SHA256 / EXPECTED_META_SHA256, the hashlib/hmac imports, and VaultLoadError). Could you rebase onto the latest main and re-apply just the file-handle with blocks on top of the current code? Once it's rebased with no conflicts and CI is green, I'll review and merge.

Quick steps:

git remote add upstream https://github.com/CyberSunil/LLMVault.git # once
git fetch upstream
git checkout fix-expert-vault-open-file-handles
git rebase upstream/main # resolve conflicts, KEEP main's integrity checks, add your with-blocks
git push --force-with-lease

This branch has not been deployed

No deployments
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.

File handles left open in expert_vault.py

2 participants