-
Notifications
You must be signed in to change notification settings - Fork 568
Description
Description
Summary
On a fresh install with little/no PMS data, some dashboard charts log JavaScript errors and fail to render gracefully. The PMS endpoints return 200 OK with a message-only JSON body (e.g., {"message":"No records available at the moment."}
), while the front-end assumes labels
/datasets
arrays and calls .length
on undefined
. Charts that do have data render fine.
Environment
- Horilla: branch
1.0
, commit7560e935
- Python: 3.12 • Gunicorn: 23.0.0
- OS/Web: Ubuntu + Nginx 1.24 (behind AWS CloudFront)
- DB: AWS RDS PostgreSQL 16.8
- Cache/Sessions: Redis (AWS ElastiCache 7.1) via
django-redis
- Site:
https://hr.***.net/
Notes
- This occurs only for widgets with no data; other charts render correctly.
Steps to Reproduce
Steps to Reproduce
- Fresh instance (no PMS objectives/feedback/key results yet).
- Log in → open Dashboard.
- Check DevTools Console and Network (XHR).
Expected Behavior
Expected Behavior
Empty PMS widgets should not throw errors. Prefer one of:
-
Backend: return a consistent empty shape, e.g.
{"labels": [], "datasets": []}
-
Frontend: coerce missing keys to empty arrays before passing to Chart.js:
const labels = Array.isArray(resp?.labels) ? resp.labels : []; const datasets = Array.isArray(resp?.datasets) ? resp.datasets : []; if (datasets.length) { /* build chart */ } else { /* show empty state */ }
Actual Behavior
Actual Behavior
-
Console shows errors like:
chart.js:13 Uncaught TypeError: Cannot read properties of undefined (reading 'length') ... pmsChart.js:60 objectiveStatusDataUpdate pmsChart.js:159 keyResultStatusDataUpdate pmsChart.js:243 feedbackStatusDataUpdate
-
Example endpoint returns 200 with message-only JSON:
-
GET /pms/dashboard-feedback-status
-
Content-Type: application/json
-
Body:
{"message": "No records available at the moment."}
-
Screenshots
No response
Django Version
na
Python Version
3.12
Operating System
Ubuntu 24.04
Browser
No response
Additional Information
No response
Possible Solution
No response
Labels
bug
Priority
Medium
Assignees
No response
Related Issues
No response
Submission Checklist
- I have searched for duplicate issues
- I have provided as much detail as possible