Skip to content

fix: use missing_ok for temp file cleanup to avoid masking errors - #3820

Open
Quratulain-bilal wants to merge 2 commits into
github:mainfrom
Quratulain-bilal:fix/presets-registry-encoding
Open

fix: use missing_ok for temp file cleanup to avoid masking errors#3820
Quratulain-bilal wants to merge 2 commits into
github:mainfrom
Quratulain-bilal:fix/presets-registry-encoding

Conversation

@Quratulain-bilal

Copy link
Copy Markdown
Contributor

Replace if temp_path.exists(): temp_path.unlink() with emp_path.unlink(missing_ok=True) in 3 files: integrations/manifest.py, shared_infra.py, _utils.py. The old pattern could raise OSError if unlink() fails, masking the original exception in inally/except blocks.

Copilot AI 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.

Pull request overview

This PR attempts to prevent temporary-file cleanup from masking write failures.

Changes:

  • Replaces existence checks with Path.unlink(missing_ok=True) in three atomic-write paths.
  • However, non-FileNotFoundError cleanup failures can still mask original exceptions.
Show a summary per file
File Description
src/specify_cli/shared_infra.py Updates shared-file cleanup.
src/specify_cli/integrations/manifest.py Updates manifest cleanup.
src/specify_cli/_utils.py Updates settings JSON cleanup.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Medium

Comment thread src/specify_cli/shared_infra.py Outdated
Comment thread src/specify_cli/integrations/manifest.py Outdated
Comment thread src/specify_cli/_utils.py Outdated
Wrap unlink(missing_ok=True) in try/except OSError in finally/except blocks
to prevent cleanup failures from masking the original exception.
@Quratulain-bilal
Quratulain-bilal force-pushed the fix/presets-registry-encoding branch from 4c32666 to bbe9657 Compare July 29, 2026 13:24
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.

3 participants