Skip to content

Commit 0d174d0

Browse files
fix: catch OSError in streaming dispatch_command() for missing/unexecutable binaries
The streaming branch only caught KeyboardInterrupt but not OSError. If the binary is removed between shutil.which() and subprocess.run() (a TOCTOU race), an OSError propagates unhandled.
1 parent 36cb7e3 commit 0d174d0

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/specify_cli/integrations/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,12 @@ def dispatch_command(
401401
"stdout": "",
402402
"stderr": "Interrupted by user",
403403
}
404+
except OSError as exc:
405+
return {
406+
"exit_code": 1,
407+
"stdout": "",
408+
"stderr": f"Failed to execute command: {exc}",
409+
}
404410
return {
405411
"exit_code": result.returncode,
406412
"stdout": "",

src/specify_cli/integrations/copilot/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ def dispatch_command(
314314
"stdout": "",
315315
"stderr": "Interrupted by user",
316316
}
317+
except OSError as exc:
318+
return {
319+
"exit_code": 1,
320+
"stdout": "",
321+
"stderr": f"Failed to execute command: {exc}",
322+
}
317323
return {
318324
"exit_code": result.returncode,
319325
"stdout": "",

0 commit comments

Comments
 (0)