medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
468 stars 218 forks source link

Error accessing tasks thrown after upgrade when refreshing stale targets #9552

Closed dianabarsan closed 1 month ago

dianabarsan commented 1 month ago

Describe the bug When loading tasks or targets for the first time after the upgrade to 4.13, this error can occur. Image

To Reproduce Steps to reproduce the behavior:

  1. Install 4.12
  2. Create an offline user. Log in with this offline user and create one pregnancy. Logout.
  3. Login as admin and upgrade to 4.13.x . Logout.
  4. Log in as the offline user again and navigate to tasks or targets page.
  5. See error.

Expected behavior No error.

Logs

main.js:1 Error getting targets TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Object.aggregateStoredTargetEmissions (main.js:1:1309050)
    at Object.<anonymous> (main.js:1:1306901)
    at Generator.next (<anonymous>)
    at w (main.js:11:600733)
    at x (main.js:11:600945)
    at main.js:11:601004
    at new r (polyfills.js:1:22887)
    at Object.<anonymous> (main.js:11:600886)
    at A.aggregateStoredTargetEmissions (main.js:1:1307030)

Screenshots

Environment

Additional context This is due to a change in structure of the local rulesStateStore document.

dianabarsan commented 1 month ago

Fixed in master and backported to 4.13.x

kennsippell commented 1 month ago

Reactivating due to similar bug:

  1. Install 4.12
  2. Create an offline user. Log in with this offline user and create one pregnancy. Logout.
  3. Login as admin and upgrade to 4.13.x . Logout.
  4. Move calendar forward to start of next month
  5. Log in as the offline user again and navigate to tasks or targets page.
  6. See error.
dianabarsan commented 1 month ago

Is this intervalturnover?????!!!

kennsippell commented 1 month ago

Yes

garethbowen commented 1 month ago

Second patch has been merged and backported.