OpenFn / primero-progres

Interoperability solution for UNICEF <> UNHCR interagency referrals between Primero and Progres v4 systems.
https://openfn.github.io/primero-progres/
0 stars 2 forks source link

f1-1.sendReferralsToPrimero passing on platform but logs are not showing Primero API response #52

Closed daissatou2 closed 2 years ago

daissatou2 commented 2 years ago

Describe the bug

The f1-1.sendReferralsToPrimero job in the production project seems to be stopping before the updateCase operation runs. In this run log, the last console.log statement is from line 237 of the job.

Why aren't we seeing a response from the Primero API? Is the operation failing but the job isn't showing an error message?

Compare the production log to a log from the staging project from a couple of months ago. They both used the same adaptor version but the staging project log is complete.

To Reproduce

  1. Here is a link to a failed run on OpenFn.org wihch is indicative of the bug: https://www.openfn.org/projects/primero-progres-v4-prod/runs/062a35c9-aa3a-728b-8962-f5dce6d18b2e

expression.js

Link to the job itself in Github: https://github.com/OpenFn/primero-progres/blob/master/jobs/PROD/f1-1.sendReferralsToPrimero.js

state.json

https://www.openfn.org/projects/primero-progres-v4-prod/messages/062a35a3-3e1f-7d5b-9abc-d90545a719db

Expected behavior

The job should execute the updateCase operation and output the response from the Primero API. It should also throw an error if there is an issue with executing that operation.

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 (link) and confirming success.]
aleksa-krolls commented 2 years ago

@taylordowns2000 after my Slack DM is addressed, this is the next priority UNICEF issue to review. This error was thrown in prod environments, but during a prod test (so the data is test data). We need to confirm ASAP this is not an issue on our side, and whether there are any Progres/DTP error messages we need to share back with UNHCR.

taylordowns2000 commented 2 years ago

Hey @daissatou2 , @aleksa-krolls , I'm digging in, and the concept of providing a log from when it's working as expected and another log when it's not working is fantastic, but the two actual runs provided are apples and orange. The "bad" one is doing an update on an existing case. The "good" one is creating a new case.

I'll see what I can learn about the update part of the job, but it would be super helpful if you could provide me with an example of a run that does an update but is working as expected. Does that make sense?

taylordowns2000 commented 2 years ago

@daissatou2 , @aleksa-krolls , this PR seems to do the trick. My assessment of the issue is that everything worked as expected, and there's no change in behaviour from the Primero side, but that this particular adaptor version (v2.3.4) does not write the Primero response to the console after an update.

That's simply the behaviour of the adaptor. If I had to guess, we wanted to "say less" in the logs to give folks the flexibility/security to log what they want in the callback, but IMO we should have, at least, printed a "that worked" line after the success response from Primero.

This is a fairly old adaptor version, so I think that any desired changes should be implemented on the new version and we should (carefully) upgrade the job. Let me know if you want to discuss today. None of this is strictly necessary as the logs now show the outcome you want, but upgrading to the latest Primero is probably a good idea at some point in the future anyway.