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

False success: Primero `500` error is showing as successful run in OpenFn #41

Closed aleksa-krolls closed 2 years ago

aleksa-krolls commented 3 years ago

Describe the bug

See the false success run: https://www.openfn.org/projects/p5am6e/runs/0616ecab-7553-7af0-abf6-5708f4b129a4

Fetching by case id...
(node:16452) UnhandledPromiseRejectionWarning: Error: Server responded with:
{
  "statusCode": 500,
  "body": "{\"errors\":[{\"status\":500,\"resource\":\"/api/v2/cases\",\"message\":\"No field configured for Child with name 'case_id'\"}]}", 

To Reproduce

Feel free to re-run on prod. We expect this to find the matching case & referral... and update the referral status in Primero.

adaptor

language-primero@2.3.3

expression.js

jobs/2.c.uploadDecisionsV2.js

state.json

See LP for Primero Gambella open_function API user https://www.openfn.org/projects/p5am6e/messages/0616ecab-5cad-7810-b6d0-9cf8011c19d4

lakhassane commented 3 years ago

@aleksa-krolls there was an error with typo preventing from throwing error. This is fixed and I updated the job to use the last version : https://www.openfn.org/projects/p5am6e/runs/0617046a-d490-7b37-91b3-7cf0bc32f2e2

I updated the others also.

aleksa-krolls commented 3 years ago

@lakhassane Okay, cool. Noted re: v2.3.4!

Now can you help me solve the 500 error :-) This was working before... see example successful run below: https://www.openfn.org/projects/p5am6e/runs/06168c23-52ed-728d-907e-9ff85d13cf25

aleksa-krolls commented 2 years ago

@lakhassane Quoin confirmed that the way we should query cases by case_id will be the same (e.g., /api/v2/cases?case_id=a884ef1e-768d-417e-a203-2481bd3c7c90), so the approach and adaptor should stay the same. But I will let you know when the API bug is resolved so that you can continue work on this issue.

aleksa-krolls commented 2 years ago

@lakhassane Quoin has deployed fix that will allow you to query by case_id so please resume this issue. E.g., GET '/api/v2/cases?case_id=e118082a-068f-47e1-96e2-31f9e8f7353b'

lakhassane commented 2 years ago

@aleksa-krolls if they deployed the fix this issue should auto-solve I would say. Im having a green check here: https://www.openfn.org/projects/p5am6e/runs/06181305-b1c5-77c9-bb7d-415da46b3a7b

But no cases. Also not hitting 500 with postman anymore.

aleksa-krolls commented 2 years ago

@lakhassane It looks like this case_id query doesn't work if cases were created before the patch fix. I've reached out to Quoin. cc @daissatou2 pls ask me about this

In the meantime, I have it working for a more recent case here: https://www.openfn.org/projects/p5am6e/runs/061813fb-3cad-7e6f-a32b-1a39bdf9c21d

Request: If case is NOT found, can you please throw an error and force the job to fail with the error No case found. Referral decision cannot be synced? Here is a sample state: https://www.openfn.org/projects/p5am6e/messages/0616ecab-5cae-7297-ab0e-5a9c19b4d3a2

lakhassane commented 2 years ago

@aleksa-krolls throwing error when case not found: https://www.openfn.org/projects/p5am6e/runs/06181a4d-cdad-7066-956a-d1940c80efbc

aleksa-krolls commented 2 years ago

@lakhassane Looking great, thank you!