Skip to content

Commit 5cb30dc

Browse files
stainless-app[bot]batuhan
authored andcommitted
fix: more gracefully handle empty stdin input
1 parent 0eb313f commit 5cb30dc

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

pkg/cmd/flagoptions.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,16 @@ func flagOptions(
217217
flagContents := requestflag.ExtractRequestContents(cmd)
218218

219219
var bodyData any
220+
var pipeData []byte
220221
if isInputPiped() && !stdinInUse {
221222
var err error
222-
pipeData, err := io.ReadAll(os.Stdin)
223+
pipeData, err = io.ReadAll(os.Stdin)
223224
if err != nil {
224225
return nil, err
225226
}
227+
}
226228

229+
if len(pipeData) > 0 {
227230
if err := yaml.Unmarshal(pipeData, &bodyData); err == nil {
228231
if bodyMap, ok := bodyData.(map[string]any); ok {
229232
if flagMap, ok := flagContents.Body.(map[string]any); ok {

0 commit comments

Comments
 (0)