Skip to content

Commit 18591c0

Browse files
committed
Don't surface errors when site has started
1 parent 2bb9d4f commit 18591c0

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

  • src/azure-cli/azure/cli/command_modules/appservice

src/azure-cli/azure/cli/command_modules/appservice/custom.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2489,10 +2489,15 @@ def format_webapp_status_output(result):
24892489
from collections import OrderedDict
24902490

24912491
items = _extract_webapp_status_items(result)
2492-
# LastError is a nullable field on the backend SiteRuntimeStatusOnWorker contract,
2493-
# so the error columns (LastError, LastErrorDetails, LastErrorTimestamp) are only
2494-
# surfaced when at least one instance reports a LastError.
2495-
show_errors = any(item.get('lastError') for item in items)
2492+
2493+
# LastError is a nullable field on the backend SiteRuntimeStatusOnWorker contract.
2494+
# A 'Started' instance is healthy, so any LastError it still carries is stale and
2495+
# must not be shown. We surface the error columns (LastError, LastErrorDetails,
2496+
# LastErrorTimestamp) only when an instance reports a LastError while NOT 'Started'.
2497+
def _has_visible_error(item):
2498+
return bool(item.get('lastError')) and item.get('state') != 'Started'
2499+
2500+
show_errors = any(_has_visible_error(item) for item in items)
24962501

24972502
rows = []
24982503
for item in items:
@@ -2502,9 +2507,14 @@ def format_webapp_status_output(result):
25022507
('Action', item.get('action'))
25032508
])
25042509
if show_errors:
2505-
row['LastError'] = item.get('lastError')
2506-
row['LastErrorDetails'] = item.get('lastErrorDetails')
2507-
row['LastErrorTimestamp'] = item.get('lastErrorTimestamp')
2510+
if _has_visible_error(item):
2511+
row['LastError'] = item.get('lastError')
2512+
row['LastErrorDetails'] = item.get('lastErrorDetails')
2513+
row['LastErrorTimestamp'] = item.get('lastErrorTimestamp')
2514+
else:
2515+
row['LastError'] = None
2516+
row['LastErrorDetails'] = None
2517+
row['LastErrorTimestamp'] = None
25082518
row['Details'] = item.get('details')
25092519
row['DetailsLevel'] = item.get('detailsLevel')
25102520
rows.append(row)

0 commit comments

Comments
 (0)