Improve error messages for batch machine translation
Is your feature request related to a problem? Please describe. Users only get "translation failed" when they batch translate. I had to dig into server logs to find the real message.
They see:
Real error message, which is the second exception below "Google Translate is not injected":
io.tolgee.batch.RequeueWithDelayException: translation_failed null
at io.tolgee.batch.MtProviderCatching.iterateCatching(MtProviderCatching.kt:61)
at io.tolgee.batch.processors.GenericAutoTranslationChunkProcessor.process(GenericAutoTranslationChunkProcessor.kt:32)
at io.tolgee.batch.processors.MachineTranslationChunkProcessor.process(MachineTranslationChunkProcessor.kt:28)
at io.tolgee.batch.ChunkProcessingUtil.processChunk(ChunkProcessingUtil.kt:35)
at io.tolgee.batch.BatchJobActionService.handleItem$lambda$1$lambda$0(BatchJobActionService.kt:70)
at io.tolgee.util.TransactionUtilKt.executeInNewTransaction$lambda$0(transactionUtil.kt:22)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
at io.tolgee.util.TransactionUtilKt.executeInNewTransaction(transactionUtil.kt:21)
at io.tolgee.util.TransactionUtilKt.executeInNewTransaction$default(transactionUtil.kt:11)
at io.tolgee.util.TransactionUtilKt.executeInNewTransaction(transactionUtil.kt:30)
at io.tolgee.batch.BatchJobActionService.handleItem$suspendImpl(BatchJobActionService.kt:56)
at io.tolgee.batch.BatchJobActionService.handleItem(BatchJobActionService.kt)
at io.tolgee.batch.BatchJobConcurrentLauncher$handleItem$job$1.invokeSuspend(BatchJobConcurrentLauncher.kt:195)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702)
Caused by: java.lang.IllegalStateException: Google Translate is not injected
at io.tolgee.component.machineTranslation.providers.GoogleTranslationProvider.translateService_delegate$lambda$0(GoogleTranslationProvider.kt:34)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:83)
at io.tolgee.component.machineTranslation.providers.GoogleTranslationProvider.getTranslateService(GoogleTranslationProvider.kt:33)
at io.tolgee.component.machineTranslation.providers.GoogleTranslationProvider.translateViaProvider(GoogleTranslationProvider.kt:21)
at io.tolgee.component.machineTranslation.providers.AbstractMtValueProvider.translate(AbstractMtValueProvider.kt:33)
at io.tolgee.component.machineTranslation.MtServiceManager.translate(MtServiceManager.kt:53)
at io.tolgee.service.machineTranslation.MtBatchTranslator.translateInSingleRequest(MtBatchTranslator.kt:91)
at io.tolgee.service.machineTranslation.MtBatchTranslator.translateInSingleRequest$default(MtBatchTranslator.kt:83)
at io.tolgee.service.machineTranslation.MtBatchTranslator.translateItem(MtBatchTranslator.kt:35)
at io.tolgee.service.machineTranslation.MtBatchTranslator.translate(MtBatchTranslator.kt:19)
at io.tolgee.service.machineTranslation.MtTranslator.translate(MtTranslator.kt:30)
at io.tolgee.service.machineTranslation.MtService.getMachineTranslations(MtService.kt:28)
at io.tolgee.service.machineTranslation.MtService.getMachineTranslations(MtService.kt:19)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:355)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:769)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:379)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:769)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:721)
at io.tolgee.service.machineTranslation.MtService$$SpringCGLIB$$0.getMachineTranslations(<generated>)
at io.tolgee.service.translation.AutoTranslationService.autoTranslateUsingMachineTranslation(AutoTranslationService.kt:261)
at io.tolgee.service.translation.AutoTranslationService.autoTranslateSync(AutoTranslationService.kt:199)
at io.tolgee.batch.processors.GenericAutoTranslationChunkProcessor.process$lambda$4(GenericAutoTranslationChunkProcessor.kt:36)
at io.tolgee.batch.MtProviderCatching.iterateCatching(MtProviderCatching.kt:33)
... 20 more
Describe the solution you'd like Please show the user the real message so that they and we can more easily support the problem.
Describe alternatives you've considered N/A
Additional context N/A
Thanks for bringing this to our attention. You're right, "Translation failed" is too generic and makes troubleshooting difficult. It's definitely important that users receive informative error messages, especially when dealing with batch operations.
We'll investigate this issue and discuss the best way to surface the underlying error to the user with my colleagues.
We'll keep you updated. Thanks again! 🙌