The SDK does not expose Multi-status errors when parsing the response for batch operations, making it impossible to detect errors in batch operations. As can be seen (for example) in the generated code for the Hubspot::Crm::Objects::Calls::BatchApi.upsert_with_http_info method, the return type is hardcoded to BatchResponseSimplePublicUpsertObject.
|
return_type = opts[:debug_return_type] || 'BatchResponseSimplePublicUpsertObject' |
Instead of being hardcoded, the response type should be one of BatchResponseSimplePublicUpsertObject or BatchResponseSimplePublicUpsertObjectWithErrors, depending on if all the operations in the batch succeeded or not.
Example
Here's an example of a batch request that fails with a validation error with client debugging enabled:
ETHON: performed EASY effective_url=https://api.hubapi.com/crm/v3/objects/<object_id>/batch/upsert response_code=207 return_code=ok total_time=0.456076
HTTP response body ~BEGIN~
{
"status":"COMPLETE",
"results":[],
"numErrors":1,
"errors":[
{
"status":"error",
"category":"VALIDATION_ERROR",
"message":"Property values were not valid: [{\"isValid\":false,\"message\":\"Enter a number no more than 10\",\"error\":\"MAX_NUMBER\",\"name\":\"gross_total\"}]",
"context":{"objectWriteTraceId":["143","146","145"]}
}
],
"startedAt":"2025-04-12T02:54:48.893Z",
"completedAt":"2025-04-12T02:54:49.030Z"
}
~END~
And the incorrect object being returned:
0> response.class
=> Hubspot::Crm::Objects::BatchResponseSimplePublicUpsertObject
0> response.to_json
=> {"completedAt":"2025-04-12T02:54:49.030Z","startedAt":"2025-04-12T02:54:48.893Z","results":[],"status":"COMPLETE"}
The SDK does not expose Multi-status errors when parsing the response for batch operations, making it impossible to detect errors in batch operations. As can be seen (for example) in the generated code for the
Hubspot::Crm::Objects::Calls::BatchApi.upsert_with_http_infomethod, the return type is hardcoded toBatchResponseSimplePublicUpsertObject.hubspot-api-ruby/lib/hubspot/codegen/crm/objects/calls/api/batch_api.rb
Line 346 in 389fed0
Instead of being hardcoded, the response type should be one of
BatchResponseSimplePublicUpsertObjectorBatchResponseSimplePublicUpsertObjectWithErrors, depending on if all the operations in the batch succeeded or not.Example
Here's an example of a batch request that fails with a validation error with client debugging enabled:
And the incorrect object being returned: