Skip to content

fix. Exclude WeaviateErrorMessage#throwable field from gson (de)seria… #205

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

Merged

Conversation

ita-jp
Copy link
Contributor

@ita-jp ita-jp commented May 10, 2023

Problem

If an error occurs in weaviate, the gson serialization always fails and a WeaviateError object holding the gson error is returned.

As a result, it is hard for developers to write recovery processing by distinguishing the cause of the error.

WeaviateErrorMessage(message=Failed making field 'java.lang.Throwable#detailMessage' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type., throwable=com.google.gson.JsonIOException: Failed making field 'java.lang.Throwable#detailMessage' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type.)

Additionally, as mentioned in #201, SerializerTest.{testErrorResponseWithNoError,testErrorResponse} is fail.

com.google.gson.JsonIOException: Failed making field 'java.lang.Throwable#detailMessage' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type.

Cause

From Java 17, gson cannot access the private fields for each class by reflection.

Solution

In this PR, the transient keyword is added to WeaviateErrorMessage#throwable field to exclude from gson serialization/deserialization.
WeaviateErrorMessage#throwable is only used on Java, so it does not need to serialize/deserialize by gson.

@weaviate-git-bot
Copy link

To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge.

beep boop - the Weaviate bot 👋🤖

PS:
Are you already a member of the Weaviate Slack channel?

@ita-jp
Copy link
Contributor Author

ita-jp commented May 12, 2023

To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge.beep boop - the Weaviate bot 👋🤖PS:Are you already a member of the Weaviate Slack channel?

I agree with the CLA.

@antas-marcin antas-marcin merged commit b480fcf into weaviate:main May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants