OpenFn / grassroot-soccer

Grassroot Soccer CommCare-Salesforce integrations
https://openfn.github.io/grassroot-soccer/
0 stars 0 forks source link

Upsert Risk & Vulnerability Assessment | Service Referral job failure #28

Closed daissatou2 closed 3 years ago

daissatou2 commented 3 years ago

Describe the bug

I made a change to the Upsert Risk & Vulnerability Assessment | Service Referral job today to address an issue the client flagged. However, my changes are currently failing. Basically, there are various versions of this job that we need to be able to handle.

Feel free to revert my changes from today, the intended changes are below:

  1. We only want to upsert a NewReferral if referral_services is in the message (like this message). Here's another message where referral_services is missing and so the job should end gracefully and log a message that says "no referrals to upsert".
  2. When we are upserting referrals, the CommCare_Ext_ID__c field can come from 1 of two places: state.data.form.subcase_0.case['@case_id'] like in this message AND/OR state.data.form.referral_services.art_support_services.skillz_plus_club_details.create_skillz_plus_club_participant_case.case['@case_id'] like in this message.

If neither of these fields for the CommCare_Ext_ID__c are present (even though referral_services is), the job should again end gracefully and log a message that says "no referrals to upsert". Example message here. (If both are present just pick anyone, the ID will be the same).

To Reproduce

  1. Here is a link to a failed run on OpenFn.org which is indicative of the bug: https://www.openfn.org/projects/pd3yk4/messages/mrb5m87a

expression.js

Link to the job itself in Github: https://github.com/OpenFn/grassroot-soccer/blob/master/jobs/upsertRiskVulnerabilityNewReferrals.js

state.json

referral_services present: https://www.openfn.org/projects/pd3yk4/messages/mwbebqka referral_services missing: https://www.openfn.org/projects/pd3yk4/messages/mrb5m87a referral_services & CommCare_Ext_ID__C type 1 present: https://www.openfn.org/projects/pd3yk4/messages/mpq8gb3q referral_services & CommCare_Ext_ID__C type 2 present: https://www.openfn.org/projects/pd3yk4/messages/m3p4p3vp referral_services present but fields for CommCare_Ext_ID__C missing: https://www.openfn.org/projects/pd3yk4/messages/mn58k3qz

Expected behavior

See above. Everything else in this job relating to Risk Assessment should remain the same.

To test/resolve

  1. After the desired output is working locally (from the CLI), please [push commits to master || open a pull request].
  2. [Please test the change on OpenFn.org by re-running this run the job against the state files above and confirming success.]
lakhassane commented 3 years ago

@daissatou2 changes done referral_services present: https://www.openfn.org/projects/pd3yk4/runs/renm57xd referral_services missing: https://www.openfn.org/projects/pd3yk4/runs/rmknyr6z referral_services & CommCare_Ext_ID__C type 1 present: https://www.openfn.org/projects/pd3yk4/runs/r5e8awkg referral_services & CommCare_Ext_ID__C type 2 present: https://www.openfn.org/projects/pd3yk4/runs/raay3eje referral_services present but fields for CommCare_Ext_ID__C missing: https://www.openfn.org/projects/pd3yk4/runs/rya4je6g

The last one is failing but I assume it's normal since there is no CommCare_Ext_ID__C to upsert with.