Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clap_complete: generate() shouldn't panic if writing fails #5457

Open
2 tasks done
yedayak opened this issue Apr 15, 2024 · 0 comments
Open
2 tasks done

clap_complete: generate() shouldn't panic if writing fails #5457

yedayak opened this issue Apr 15, 2024 · 0 comments
Labels
C-bug Category: Updating dependencies M-breaking-change Meta: Implementing or merging this will introduce a breaking change.

Comments

@yedayak
Copy link

yedayak commented Apr 15, 2024

Please complete the following tasks

  • I have searched the discussions

  • I have searched the existing issues

Rust Version

rustc 1.77.2 (25ef9e3d8 2024-04-09)

Clap Version

master

Actual Behaviour

Running generate() can panic, for example if writing to a pipe ans the next program stops, or anything really stops the generation from completing.
For example

cmd --generate | head

with a long enough completion will panic.

Expected Behaviour

generate() should return a Result indicating if it fails. This will be a breaking change.

Additional Context

Maybe we ignore some errors? I'm not sure what consumers will want to do with the error, and some of them might be not important enough to propagate, for example a broken pipe.
The panic happens here:

Err(..) => panic!("Failed to write to generated file"),

Opened after suggestion in #5453.

@epage epage added A-completion Area: completion generator M-breaking-change Meta: Implementing or merging this will introduce a breaking change. C-bug Category: Updating dependencies and removed A-completion Area: completion generator labels Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Updating dependencies M-breaking-change Meta: Implementing or merging this will introduce a breaking change.
Projects
None yet
Development

No branches or pull requests

2 participants