Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pr_agent/git_providers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def apply_repo_settings(pr_url):
try:
fd, repo_settings_file = tempfile.mkstemp(suffix='.toml')
os.write(fd, repo_settings)
os.close(fd)
Comment on lines 37 to +39
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.

Action required

1. fd not closed on error 📘 Rule violation ⛯ Reliability

The new os.close(fd) is not protected by a finally, so an exception from `os.write(fd,
repo_settings)` can still leak the file descriptor. This does not fully meet the robust
error-handling requirement for cleanup on failure paths.
Agent Prompt
## Issue description
`os.close(fd)` is executed only if `os.write(fd, repo_settings)` succeeds; if `os.write` raises, the file descriptor can still leak.

## Issue Context
This code uses `tempfile.mkstemp()` which returns a raw OS file descriptor that must be closed on all paths (success and exception).

## Fix Focus Areas
- pr_agent/git_providers/utils.py[37-39]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


try:
dynconf_kwargs = {'core_loaders': [], # DISABLE default loaders, otherwise will load toml files more than once.
Expand Down