Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Direct self-reference leading to cycle #1891

Closed
ie-senol opened this issue Jan 12, 2022 · 10 comments
Closed

[BUG] Direct self-reference leading to cycle #1891

ie-senol opened this issue Jan 12, 2022 · 10 comments
Assignees
Labels
bug Something isn't working Indexing & Search

Comments

@ie-senol
Copy link

Describe the bug
When a failure is met with one or more operations included in the bulk request, the ObjectMapper.writeValueAsString that we use to convert the bulk response throws the following exception:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException:
Direct self-reference leading to cycle

and fails to convert the Bulkresponse.

With ElasticSearch, however, it works just fine and never throws this exception.

We use RestHighLevelClient for both.

To Reproduce
Steps to reproduce the behavior:

  1. Run the following piece of code
ObjectMapper objectMapper = new ObjectMapper();
try {
    String jsonArray = objectMapper.writeValueAsString( bulkResponse.getItems() );
}
catch ( JsonProcessingException jsonProcessingException ) {
    log.error( jsonProcessingException.getMessage() );
    throw new RuntimeException( jsonProcessingException );
}
  1. See the following error:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException:
Direct self-reference leading to cycle
(
through reference chain:
org.elasticsearch.action.bulk.BulkItemResponse[2]->
org.elasticsearch.action.bulk.BulkItemResponse["failure"]->
org.elasticsearch.action.bulk.BulkItemResponse$Failure["cause"]->
org.elasticsearch.ElasticsearchException["rootCause"]
)

Expected behavior
ObjectMapper.writeValueAsString should return JSON formatted text output of Bulkresponse without exception.

Plugins
Please see the list of all plugins currently enabled.
image

Host/Environment (please complete the following information):

  • MacOS 12.0.1
  • opensearch:latest

Additional context
The same code doesn't throw any exception and works well with ElasticSearch.

@ie-senol ie-senol added bug Something isn't working untriaged labels Jan 12, 2022
@anasalkouz
Copy link
Member

anasalkouz commented Jan 18, 2022

Hi @ersinoracle, Could you share the object before the serialization? the output of bulkResponse.getItems(), so we can reproduce it. In addition, could share more details about your use-case? what is the problem you are trying to solve?

@ie-senol
Copy link
Author

ie-senol commented Jan 20, 2022

Please see the answers below.

Use-case:

  • Call bulk API using the payload which is assigned into the requestBody actual parameter
  • Convert the response to JSON so to return it to the caller

Problem:

  • ObjectMapper throws exception com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Direct self-reference leading to cycle.

Files attached (had to add .txt at the end of each file extension to be able to attach):

@ie-senol
Copy link
Author

Any updates yet?

@dblock dblock added the v1.3.0 label Mar 1, 2022
@dblock
Copy link
Member

dblock commented Mar 1, 2022

I labeled this for 1.3.0 so we don't miss it.

@ersinoracle Try turning this into a unit test if you have a moment?

@ie-senol
Copy link
Author

ie-senol commented Mar 1, 2022

@dblock I, unfortunately, won't have time to write a unit test for this. But, I'll be waiting for you to address and resolve the issue hopefully in 1.3.0.

@anasalkouz anasalkouz added v2.1.0 Issues and PRs related to version 2.1.0 and removed v1.4.0 v1.3.0 labels Apr 1, 2022
@anasalkouz anasalkouz self-assigned this Apr 1, 2022
@anasalkouz
Copy link
Member

Hey @ersinoracle, Sorry for being late. are you currently try to use elasticsearch client to query OpenSearch cluster.?Because the error has elasticsearch, I want to confirm this before diving into the issue.
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Direct self-reference leading to cycle ( through reference chain: org.elasticsearch.action.bulk.BulkItemResponse[2]-> org.elasticsearch.action.bulk.BulkItemResponse["failure"]-> org.elasticsearch.action.bulk.BulkItemResponse$Failure["cause"]-> org.elasticsearch.ElasticsearchException["rootCause"] )

@ie-senol
Copy link
Author

ie-senol commented Apr 4, 2022

Hi @anasalkouz, yes we still have been using it to query the OpenSearch cluster.

@anasalkouz
Copy link
Member

Starting with version 7.14, multiple of the clients maintained by Elastic start to fail query OpenSearch Cluster. I would recommend update it to the equivalent OpenSearch client. See this blog for more details

@saratvemulapalli
Copy link
Member

@anasalkouz this issue is tagged 2.1.0.
We are code freeze for 2.1. I'll move this issue to 2.2.0, let me know if you think otherwise.

@saratvemulapalli saratvemulapalli added v2.2.0 and removed v2.1.0 Issues and PRs related to version 2.1.0 labels Jun 28, 2022
@CEHENKLE CEHENKLE removed the v2.2.0 label Aug 3, 2022
@anasalkouz
Copy link
Member

Closing this issue. @ie-senol let me know if there is anything still pending on this to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Indexing & Search
Projects
None yet
Development

No branches or pull requests

6 participants