is there an error in association api description when OBJECT_NOT_FOUND is returned?

I downloaded the openapi-description with

curl --location --request GET 'https://api.hubspot.com/api-catalog-public/v1/apis/crm/v3/associations' \ --header 'accept: application/yaml' \ -o associations.yaml

and I used the openapi-generator to generated a java client for that api.

I wanted to get get all associated custom objects for a list of custom objects. It is working as long as the association available. But when one entry does not have this association I get an error

org.springframework.web.client.RestClientException: Error while extracting response for type [class com.persolog.openapi.hubspot.associations.model.BatchResponsePublicAssociationMulti] and content type [application/json;charset=utf-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of `com.persolog.openapi.hubspot.associations.model.ErrorCategory` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('OBJECT_NOT_FOUND'); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.persolog.openapi.hubspot.associations.model.ErrorCategory` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('OBJECT_NOT_FOUND')
 at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 243] (through reference chain: com.persolog.openapi.hubspot.associations.model.BatchResponsePublicAssociationMulti["errors"]->java.util.ArrayList[0]->com.persolog.openapi.hubspot.associations.model.StandardError["category"])

I looked into the association.yml and found a point that maybe wrong

StandardError: # ... properties: status: type: string id: type: string category: # working: # type: string # not working: $ref: '#/components/schemas/ErrorCategory'

when category is defined by the ref then it is not working. But with simple string-type it is working.

I requested the following endpoint:

https://api.hubapi.com/crm/v3/associations/2-106166593/2-106166588/batch/read

The complete result I got, was:

{
 "status": "COMPLETE",
 "results": [
 {
 "from": {
 "id": "311326945"
 },
 "to": [
 {
 "id": "311244245",
 "type": "referent_event"
 }
 ]
 },
 {
 "from": {
 "id": "311326914"
 },
 "to": [
 {
 "id": "311244526",
 "type": "referent_event"
 }
 ]
 }
 ],
 "numErrors": 1,
 "errors": [
 {
 "status": "error",
 "category": "OBJECT_NOT_FOUND",
 "subCategory": "crm.associations.NO_ASSOCIATIONS_FOUND",
 "message": "No persolog_referent is associated with persolog_event 311326710.",
 "context": {
 "fromObjectId": [
 "311326710"
 ],
 "fromObjectType": [
 "persolog_event"
 ],
 "toObjectType": [
 "persolog_referent"
 ]
 }
 }
 ],
 "startedAt": "2022-09-26T14:46:54.602Z",
 "completedAt": "2022-09-26T14:46:54.622Z"
}​

Was this understandable? Do you need more Info?

Is this realy a bug and should be corrected?

kind regards in advance

Hey @cl_

This from Object ID is not available check it’s existence first

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

Hi @ChehakWadhdwa ,

it is not the problem, that the object does not exist. It is a problem, that the api-description is not correct so that answer can not be parsed.

Hey @cl_

API ERROR LOG that you got is correct and there is nothing wrong with the HubSpot API that you have pinned here

It simply means that from Object ID (311326710) is not in association with the to Object (persolog_referent)

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

Hey @ChehakWadhdwa

in the response I get

“category”: “OBJECT_NOT_FOUND”

in the definition is written that

$ref: ‘#/components/schemas/ErrorCategory’

ErrorCategory is of type object but the api provides the string “OBJECT_NOT_FOUND”.

The api is working but the description of the api seems to be wrong

Hey @cl_

This might an ERROR log bug with the API response but there is nothing wrong with the API functionality.

You can try hitting the API again by adding this in the body part →

hasUniqueValue": true

Sometimes it check if the property is unique that is the reason why it throws this ERROR

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.