junghoon-vans / spring-data-meilisearch

Provide support to increase developer productivity in Java when using Meilisearch. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://junghoon-vans.github.io/spring-data-meilisearch/
Apache License 2.0
15 stars 3 forks source link

[BUG]: JacksonJsonHandler cannot parse task status enqueued #41

Closed junghoon-vans closed 1 year ago

junghoon-vans commented 1 year ago

Description

I'm currently implementing a MeilisearchTemplate class for integration with Meilisearch. In the process, I am getting the following error when using JacksonHandler.

Version

0.2.0

OS

MacOS

Steps to Reproduce

This is test code to save entity of the Movie.class.

@MeilisearchTest
@ContextConfiguration(classes = {MeilisearchTestConfiguration.class})
class MeilisearchTemplateTest {

  @Autowired
  MeilisearchOperations meilisearchTemplate;

  @Test
  void shouldSaveDocument() {
    // given
    Movie movie = new Movie();
    movie.setId("1");
    movie.setTitle("Star Wars");
    movie.setDescription("A long time ago in a galaxy far, far away...");
    movie.setGenres(new String[]{"action", "adventure", "fantasy", "sci-fi"});

    // when
    Movie saved = meilisearchTemplate.save(movie);

    // then
    assertThat(saved).isEqualTo(movie);
  }
}

Expected Behavior

None error occurs

Actual Behavior

[main] INFO org.testcontainers.utility.ImageNameSubstitutor - Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')
[main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
[main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with local Unix socket (unix:///var/run/docker.sock)
[main] INFO org.testcontainers.DockerClientFactory - Docker host IP address is localhost
[main] INFO org.testcontainers.DockerClientFactory - Connected to docker: 
  Server Version: 24.0.5
  API Version: 1.43
  Operating System: OrbStack
  Total Memory: 5253 MB
[main] INFO tc.testcontainers/ryuk:0.4.0 - Creating container for image: testcontainers/ryuk:0.4.0
[main] INFO org.testcontainers.utility.RegistryAuthLocator - Credential helper/store (docker-credential-osxkeychain) does not have credentials for https://index.docker.io/v1/
[main] INFO tc.testcontainers/ryuk:0.4.0 - Container testcontainers/ryuk:0.4.0 is starting: c77137a395ae9fb2571627c2b6f7e9a0b65699eceab8016eb5e459703e3a8a83
[main] INFO tc.testcontainers/ryuk:0.4.0 - Container testcontainers/ryuk:0.4.0 started in PT0.294142S
[main] INFO org.testcontainers.utility.RyukResourceReaper - Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
[main] INFO org.testcontainers.DockerClientFactory - Checking the system...
[main] INFO org.testcontainers.DockerClientFactory - ✔︎ Docker server version should be at least 1.6.0
[main] INFO tc.getmeili/meilisearch:v1.2.0 - Creating container for image: getmeili/meilisearch:v1.2.0
[main] INFO tc.getmeili/meilisearch:v1.2.0 - Container getmeili/meilisearch:v1.2.0 is starting: 2d58495c7f13db675f07fb2f41080090ea011cbb1be31b4012563fd6a817070c
[main] INFO tc.getmeili/meilisearch:v1.2.0 - Container getmeili/meilisearch:v1.2.0 started in PT0.915265S

io.vanslog.spring.data.meilisearch.UncategorizedMeilisearchException: Failed to save entities.

    at io.vanslog.spring.data.meilisearch.core.MeilisearchTemplate.save(MeilisearchTemplate.java:70)
    at io.vanslog.spring.data.meilisearch.core.MeilisearchTemplate.save(MeilisearchTemplate.java:60)
    at io.vanslog.spring.data.meilisearch.core.MeilisearchTemplateTest.shouldSaveDocument(MeilisearchTemplateTest.java:33)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:217)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:213)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:138)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
Caused by: java.lang.RuntimeException: Meilisearch Exception: {com.fasterxml.jackson.databind.exc.InvalidFormatException. Error=com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `com.meilisearch.sdk.model.TaskStatus` from String "enqueued": not one of the values accepted for Enum class: [SUCCEEDED, PROCESSING, ENQUEUED, FAILED, CANCELED]
 at [Source: (String)"{"taskUid":0,"indexUid":"movies","status":"enqueued","type":"documentAdditionOrUpdate","enqueuedAt":"2023-08-10T13:11:30.272061144Z"}"; line: 1, column: 43] (through reference chain: com.meilisearch.sdk.model.TaskInfo["status"])}
    at com.meilisearch.sdk.http.response.BasicResponse.create(BasicResponse.java:22)
    at com.meilisearch.sdk.HttpClient.post(HttpClient.java:96)
    at com.meilisearch.sdk.Documents.addDocuments(Documents.java:155)
    at com.meilisearch.sdk.Index.addDocuments(Index.java:159)
    at io.vanslog.spring.data.meilisearch.core.MeilisearchTemplate.save(MeilisearchTemplate.java:68)
    ... 72 more
Caused by: Meilisearch Exception: {com.fasterxml.jackson.databind.exc.InvalidFormatException. Error=com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `com.meilisearch.sdk.model.TaskStatus` from String "enqueued": not one of the values accepted for Enum class: [SUCCEEDED, PROCESSING, ENQUEUED, FAILED, CANCELED]
 at [Source: (String)"{"taskUid":0,"indexUid":"movies","status":"enqueued","type":"documentAdditionOrUpdate","enqueuedAt":"2023-08-10T13:11:30.272061144Z"}"; line: 1, column: 43] (through reference chain: com.meilisearch.sdk.model.TaskInfo["status"])}
    at com.meilisearch.sdk.json.JacksonJsonHandler.decode(JacksonJsonHandler.java:72)
    at com.meilisearch.sdk.http.response.BasicResponse.create(BasicResponse.java:15)
    ... 76 more
Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `com.meilisearch.sdk.model.TaskStatus` from String "enqueued": not one of the values accepted for Enum class: [SUCCEEDED, PROCESSING, ENQUEUED, FAILED, CANCELED]
 at [Source: (String)"{"taskUid":0,"indexUid":"movies","status":"enqueued","type":"documentAdditionOrUpdate","enqueuedAt":"2023-08-10T13:11:30.272061144Z"}"; line: 1, column: 43] (through reference chain: com.meilisearch.sdk.model.TaskInfo["status"])
    at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67)
    at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:2002)
    at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:1230)
    at com.fasterxml.jackson.databind.deser.std.EnumDeserializer._deserializeAltString(EnumDeserializer.java:415)
    at com.fasterxml.jackson.databind.deser.std.EnumDeserializer._fromString(EnumDeserializer.java:279)
    at com.fasterxml.jackson.databind.deser.std.EnumDeserializer.deserialize(EnumDeserializer.java:248)
    at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:314)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177)
    at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4825)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3772)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3740)
    at com.meilisearch.sdk.json.JacksonJsonHandler.decode(JacksonJsonHandler.java:65)
    ... 77 more

Additional Context

Errors related to this are reported in the Meilisearch-java.

However, the issue is not yet reflected in the general release. So until this is fixed, we'll have to use GsonHandler.

zsf513 commented 1 year ago

same problem. the version is 0.11.1

junghoon-vans commented 1 year ago

@zsf513 This issue is expected to be resolved in the next release of meilisearch-java. Please see the PR mentioned in the Additional Context section. This fix is not yet reflected in v0.11.1.

junghoon-vans commented 1 year ago

@zsf513 Thank you for your patience. This issue has been resolved as of version 0.5.2.