Skip to content

Commit 8702b3b

Browse files
authored
fix panic for missing a cmd to check flag on (#4705)
1 parent 4abd9bd commit 8702b3b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

internal/cli/cli.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func isValidTraceID(id string) bool {
147147
}
148148

149149
func printError(io *iostreams.IOStreams, cs *iostreams.ColorScheme, cmd *cobra.Command, err error) {
150-
if env.IS_GH_ACTION() && env.IsTruthy("FLY_GHA_ERROR_ANNOTATION") {
150+
if cmd != nil && env.IS_GH_ACTION() && env.IsTruthy("FLY_GHA_ERROR_ANNOTATION") {
151151
printGHAErrorAnnotation(cmd, err)
152152
}
153153

@@ -181,8 +181,10 @@ func printError(io *iostreams.IOStreams, cs *iostreams.ColorScheme, cmd *cobra.C
181181
fmt.Fprintln(io.ErrOut)
182182
}
183183

184-
if bool, err := cmd.Flags().GetBool(flagnames.Debug); err == nil && bool {
185-
fmt.Fprintf(io.ErrOut, "Stacktrace:\n%s\n", debug.Stack())
184+
if cmd != nil {
185+
if bool, err := cmd.Flags().GetBool(flagnames.Debug); err == nil && bool {
186+
fmt.Fprintf(io.ErrOut, "Stacktrace:\n%s\n", debug.Stack())
187+
}
186188
}
187189
}
188190

0 commit comments

Comments
 (0)