Skip to content

Fix unnecessary unwrap on potentially empty process vector#80

Open
prjanitor wants to merge 1 commit into
warpy-ai:masterfrom
prjanitor:prjanitor/8305229d205f7c84bc9fbc9e5b9c84fc628661e3
Open

Fix unnecessary unwrap on potentially empty process vector#80
prjanitor wants to merge 1 commit into
warpy-ai:masterfrom
prjanitor:prjanitor/8305229d205f7c84bc9fbc9e5b9c84fc628661e3

Conversation

@prjanitor

@prjanitor prjanitor commented Apr 1, 2026

Copy link
Copy Markdown

Summary

This PR fixes a panic that occurs in eval_command when handling Pipeline commands. The code was calling a_procs.last_mut().unwrap() without checking if a_procs is empty.

Problem

When the left side of a pipeline produces no processes (e.g., due to an error in execute_simple_command returning an empty vector), the .unwrap() call causes a runtime panic.

Solution

Added a check for a_procs.is_empty() before accessing the last element. If empty, the function returns early with an empty result, preventing the panic.

Testing

The fix handles the edge case where pipeline commands produce no processes, ensuring graceful degradation instead of a panic.


This PR was generated by PRJanitor — an automated tool that finds and fixes small bugs in open-source projects.

We respect your contribution guidelines — if your project doesn't accept bot PRs, we won't send more. You can also add a .github/prjanitor.yml file with enabled: false to opt out explicitly.

Add a check for empty a_procs before calling .last_mut().unwrap() in the
Pipeline case of eval_command. When the left side of a pipeline produces
no processes (e.g., due to an error in execute_simple_command), the
previous code would panic at runtime. Now it returns early with an empty
result.
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.

1 participant