Conversation
|
@derekperkins thoughts on above? |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #134 +/- ##
==========================================
+ Coverage 87.52% 87.68% +0.15%
==========================================
Files 9 9
Lines 1643 1648 +5
==========================================
+ Hits 1438 1445 +7
+ Misses 115 114 -1
+ Partials 90 89 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| if reqErr != nil { | ||
| data, _ := processSingleSalesforceResult(resp) | ||
| return data, reqErr |
There was a problem hiding this comment.
Returning errors in two places feels off to me. I think what I'd rather see is either:
- Unmarshaling
[]SalesforceErrorMessagesucceeded, so don't return thereqErr, return nil for the error and only return theSalesforceResult - Unmarshaling
[]SalesforceErrorMessagefailed, so just return thereqErr
There was a problem hiding this comment.
@derekperkins yeah I do see what you mean, but that's what I was getting at with the example in the PR description. For every other case, go-salesforce returns an error if the request code is a non 200. For these single DML operations, Salesforce returns an error code if the operation doesn't succeed, even if its for a Salesforce-y reason. So I feel the need to return it in both places if only to remain consistent with the API.
Part of the reason I've left this open so long is that I think its tricky and will probably be a technically breaking change. So it'll get lumped into that new major release I keep talking about.
per the docs, if there is a successful response then it returns a json response with
id,errorsarray, andsuccessboolean.if there is an error, it returns a json response of an array of errors.
fixes #132
this is weird, because the REST API for Single DMLs returns an error code if Salesforce returns a validation error, but not for the Collection APIs.
This is best demonstrated in screenshots from Postman.
Using the Single Insert, it returns a 400 response with the error.

Using the Collections Insert, it returns a 200 response with the error in the response.
This is a quirk of the API, so keeping it like this would be consistent with Salesforce, but not consistent across go-salesforce. If that makes sense.
Option 1:
Option 2:
I lean towards Option 1, because I think modifying how go-salesforce handles the API is outside the scope. It's just a wrapper.