"invalid start of a value" when trying to translate
See original GitHub issueDescribe the bug We’ve are using the package in our WinForm app using Telerik 2023.2.60653, .Net Framework 4.7.2, package latest 1.7.1 I have developed a feature where a user can select which language it wants to translate to, in our case English or Hungarian Lets say we have posts, and each post can have comments, when the user wants to translate, we translate all the comments. When translating to English it goes well, no problem, but when I want to translate to Hungarian (does not matter if the original language is Hungarian or not) I get the error showed below. Whether I translate to English first or second I get the same result I’ve been trying to reproduce the problem in a console app, but simply unable to do so, even our users have different experience, some reported that they get the error on the first try. We use HTML to display the comments, we use CefSharp to display a chromium browser inside the WinForm app.
Update 1: For me it does not matter if I do translate fast with 1-2 secs between the two requests or wait 1-2 minutes, basically every second request gets this error, whether I start with English or Hungarian. My colleagues experience difference if they wait a certain amount of time or not. I’ve tried to make demos which I could upload here making your jobs easier, but I can not make it fail… Somehow it fails in our app, but when I make a mini environment which represents our app, with the same code which makes the API call, I cant make it to fail as it does in our app
Expected behavior We get back the translation no problem
- Stack trace:
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex) at System.Text.Json.Serialization.JsonConverter
1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.<ReadAsync>d__20
1.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at DeepL.Internal.JsonUtils.<DeserializeAsync>d__41.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at DeepL.Internal.JsonUtils.<DeserializeAsync>d__3
1.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at DeepL.Translator.<TranslateTextAsync>d__8.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Our class which inherits from UserControl.<TranslateCommentList>d__114.MoveNext() in the line of our cs file
- Source:
System.Text.Json
- Path:
$
- Message:
‘<’ is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
Screenshots or sample code
private void button_click(object sender, EventArgs e)
{
RadButton translateButton = (RadButton)sender;
if (translateButton == null) return;
string targetLanguage = translateButton.Name == "translateToHungarianButton" ? LanguageCode.Hungarian : LanguageCode.EnglishAmerican;
string sourceLanguage = targetLanguage == LanguageCode.Hungarian ? "EN" : "HU";
Task.Run(async () => await TranslateText(commentList, sourceLanguage ,targetLanguage ));
}
private async Task TranslateText(string[] textsToTranslate, string sourceLanguage, string targetLanguage)
{
TextResult[] translatedTexts;
try
{
translatedTexts = await translator.TranslateTextAsync(textsToTranslate, sourceLanguage, targetLanguage, new TextTranslateOptions() { TagHandling = "xml", IgnoreTags = { "a" }, PreserveFormatting = true });
}
catch (Exception e)
{
MessageBox.Show($"Error: {e}");
throw;
}
}
If you guys need any more info please let me know! The problem could be solved with an easy fix, it might be my lack of knowledge
Issue Analytics
- State:
- Created 3 months ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
Hey! Seems like you were right about the firewall! Talked to our IT guys and seems like we had to add an “application site category” and had to allow it(?) It was not allowed in the firewall on the application layer. To be honest our IT guy talked about it briefly and I don not have too much knowledge in this specific area so I hope it says something to you! For us this will be a solution, so I guess this issue is solved!
Could it be from this: UserCheck ? I’m not aware DeepL uses this, so it might be on your side, the WebApp seems to call itself UserCheck and this was the main thing google could find. (There are also a lot of PORTAL_IS strings, but I don’t think they mean anything)