antonio-mello-ai opened a new pull request, #62900:
URL: https://github.com/apache/airflow/pull/62900

   ## Summary
   
   - Adds defensive optional chaining (`?.`) to nested property access in 
`Health.tsx` for `metadatabase`, `scheduler`, and `triggerer` objects
   - Prevents dashboard crash (`TypeError: Cannot read properties of 
undefined`) when the `/api/v2/monitor/health` endpoint returns an error or 
empty response
   - The `ErrorAlert` component already handles error display but could not 
render because the crash occurred first during props evaluation
   
   ## Root Cause
   
   When the health API returns an error (e.g., proxy misconfiguration, network 
timeout, HTTP 400/502), `useMonitorServiceGetHealth` returns `data = 
undefined`. The existing code uses `data?.metadatabase.status` — the first `?.` 
correctly short-circuits to `undefined`, but `.status` is then called on 
`undefined`, throwing a `TypeError` that crashes the entire `/home` page.
   
   ## Changes
   
   In `Health.tsx`, 5 property accesses changed from:
   ```tsx
   data?.metadatabase.status        → data?.metadatabase?.status
   data?.scheduler.latest_*         → data?.scheduler?.latest_*
   data?.scheduler.status           → data?.scheduler?.status
   data?.triggerer.latest_*         → data?.triggerer?.latest_*
   data?.triggerer.status           → data?.triggerer?.status
   ```
   
   The `dag_processor` section was already safe (uses conditional rendering: 
`data?.dag_processor ? ... : undefined`).
   
   ## Test plan
   
   - [ ] Dashboard `/home` renders normally when health API returns valid data
   - [ ] Dashboard `/home` shows `ErrorAlert` (instead of crashing) when health 
API returns error/empty response
   - [ ] No TypeScript compilation errors
   
   Closes #62697
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to