@@ -269,6 +269,14 @@ func (b *Remote) costEstimate(stopCtx, cancelCtx context.Context, op *backend.Op
269269 return generalError ("Failed to retrieve cost estimate" , err )
270270 }
271271
272+ // If the run is canceled or errored, but the cost-estimate still has
273+ // no result, there is nothing further to render.
274+ if ce .Status != tfe .CostEstimateFinished {
275+ if r .Status == tfe .RunCanceled || r .Status == tfe .RunErrored {
276+ return nil
277+ }
278+ }
279+
272280 switch ce .Status {
273281 case tfe .CostEstimateFinished :
274282 delta , err := strconv .ParseFloat (ce .DeltaMonthlyCost , 64 )
@@ -324,18 +332,27 @@ func (b *Remote) checkPolicy(stopCtx, cancelCtx context.Context, op *backend.Ope
324332 b .CLI .Output ("\n ------------------------------------------------------------------------\n " )
325333 }
326334 for i , pc := range r .PolicyChecks {
327- logs , err := b .client .PolicyChecks .Logs (stopCtx , pc .ID )
328- if err != nil {
329- return generalError ("Failed to retrieve policy check logs" , err )
330- }
331- reader := bufio .NewReaderSize (logs , 64 * 1024 )
332-
333335 // Retrieve the policy check to get its current status.
334336 pc , err := b .client .PolicyChecks .Read (stopCtx , pc .ID )
335337 if err != nil {
336338 return generalError ("Failed to retrieve policy check" , err )
337339 }
338340
341+ // If the run is canceled or errored, but the policy check still has
342+ // no result, there is nothing further to render.
343+ if r .Status == tfe .RunCanceled || r .Status == tfe .RunErrored {
344+ switch pc .Status {
345+ case tfe .PolicyPending , tfe .PolicyQueued , tfe .PolicyUnreachable :
346+ continue
347+ }
348+ }
349+
350+ logs , err := b .client .PolicyChecks .Logs (stopCtx , pc .ID )
351+ if err != nil {
352+ return generalError ("Failed to retrieve policy check logs" , err )
353+ }
354+ reader := bufio .NewReaderSize (logs , 64 * 1024 )
355+
339356 var msgPrefix string
340357 switch pc .Scope {
341358 case tfe .PolicyScopeOrganization :
0 commit comments