JSON_PARSER_ERROR: Cannot deserialize instance of date from VALUE_STRING value
Closed this issue · 6 comments
Request
See run failure of a Person registration in Salesforce: https://www.openfn.org/projects/pdbmj5/runs/rg5nyzgy
Please edit the job as needed and re-run on Prod to ensure successful result.
state
See LP for Lwala Salesforce Production
https://www.openfn.org/projects/pdbmj5/messages/m784vmdk
expression
https://github.com/OpenFn/lwala/blob/master/commcare-salesforce-jobs/MOH513-Enroll-Person-in-SF.js
adaptor
language-salesforce
To test
Please re-run on prod: https://www.openfn.org/projects/pdbmj5/runs/rg5nyzgy
@taylordowns2000 Quick one... assigning to you to walk through with Hawa as a learning moment this week? (Otherwise feel free to hand off to Mamadou/Chaiwa)
@aleksa-krolls, we have been able to replicate the error locally however, we are not able to determine the required field that is missing. Please access the salesforce system for the missing field to enable us fix the error.
@hnyende I isolated the issue by commenting out the different date fields. Upon further review of the original error message (see below)... this is very subtle, but I think it's saying that we are trying to upload a blank/empty string value ' '
instead of a date value.
JSON_PARSER_ERROR: Cannot deserialize instance of date from VALUE_STRING value
or request may be missing a required field at...
When I look at the run failure, there are several instances where we are trying to send an empty string ' '
instead of a date value. For example, see L42 BCG__c: '',
: https://www.openfn.org/projects/pdbmj5/runs/r6grrjd6
If I remove all date fields with an empty string ' '
, I am able to successfully run the job (see here: https://www.openfn.org/projects/pdbmj5/runs/rbgee566)... so this definitely seems to be the issue.
@taylordowns2000 the mapping for BCG__c
looks the same as the other date fields like ANC_2__c
. Why does this return an empty string ' '
while the other date mappings return an undefined
value (which throws no errors)?
I want to confirm this behavior before asking @hnyende to implement a change to ensure no empty strings are returned on date fields.
lwala/commcare-salesforce-jobs/MOH513-Enroll-Person-in-SF.js
Lines 224 to 242 in 0e1a20c
Run log:
ANC_2__c: undefined,
ANC_3__c: undefined,
ANC_4__c: undefined,
ANC_5__c: undefined,
BCG__c: '',
@aleksa-krolls, Taylor and I have added a function which sets empty date strings to null and the message in question seems to be working now. Please confirm that this issue is closed. https://www.openfn.org/projects/pdbmj5/runs/raaewgax
For the future, I wonder if these empty strings will appear in other messages or this is isolated to date fields.
Great thanks @hnyende !