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

updateChatMessageTtl is not implemented and resulted in exception thrown #167

Closed
DamienLaw opened this issue Apr 12, 2023 · 11 comments
Closed
Assignees
Labels
question Further information is requested

Comments

@DamienLaw
Copy link

updateChatMessageTtl is not implemented and when received from Telegram will result in an exception thrown.

Could not create an instance of type TdLib.TdApi+Object. Type is an interface or abstract class and cannot be instantiated. Path '@type', line 1, position 9.

private void ProcessEvents()
{
var ct = _cts.Token;
while (!ct.IsCancellationRequested)
{
var data = _tdJsonClient.Receive(0.1);
if (!string.IsNullOrEmpty(data))
{
try
{
var structure = JsonConvert.DeserializeObject<TdApi.Object>(data, _converter);
Received?.Invoke(this, structure);
if (structure is TdApi.Update.UpdateAuthorizationState update)
{
AuthorizationStateChanged?.Invoke(this, update.AuthorizationState);
}
}
catch (Exception e)
{
ExceptionThrown?.Invoke(this, e);
}
}
}
}

This is because on line 54, the deserialization will fallback to TdApi.Object if the type is not found.

public abstract class Object
{
[JsonProperty("@type")] public virtual string DataType { get; set; }
[JsonProperty("@extra")] public virtual string Extra { get; set; }
}

And TdApi.Object is abstract. No deserialization can be performed on abstract class.

@ForNeVeR ForNeVeR self-assigned this Apr 13, 2023
@ForNeVeR
Copy link
Member

Any idea what exactly is this message? I cannot find it in td_api.tl from tdlib: https://github.com/tdlib/td/blob/master/td/generate/scheme/td_api.tl

@ForNeVeR
Copy link
Member

In fact, it is only mentioned in an old changelog (from 1.8.0, 2021-12-29), and nowhere else.

Are you sure it exists? Under what circumstances do you receive that?

@ForNeVeR ForNeVeR added the question Further information is requested label Apr 13, 2023
@DamienLaw
Copy link
Author

When I was running the C# sample TdLib.Samples.GetChats.

I'm only getting error on one of my accounts. But not on the other.

@ForNeVeR
Copy link
Member

Why do you think that's updateChatMessageTtl and not something else? Have you found that in debug mode?

@DamienLaw
Copy link
Author

Yes, I was running the sample in debug mode when I was hit by the exception.

image

The @type indicated that it's updateChatMessageTtl (underlined at the lower left of the screenshot).

@ForNeVeR
Copy link
Member

I would recommend opening an issue upstream.

There is no such type in the actual tdlib sources, and I don't understand how we should generate it.

@DamienLaw
Copy link
Author

DamienLaw commented Apr 18, 2023

The reference is specified here and here.

Does it help?

@ForNeVeR
Copy link
Member

These links look identical. And, unfortunately, no, it does not help.

There are still no any details about this class in the .tl specification. So, we cannot generate it. And it doesn't exist in tdlib sources.

@DamienLaw
Copy link
Author

These links look identical.

Sorry, the 2nd link supposed to be td_api.h

Perhaps, that class has been removed from the API but the server is still sending it. Is it possible to ignore unrecognised API and logs them instead of throwing unhandled exceptions and killing the client?

@ForNeVeR
Copy link
Member

Perhaps, that class has been removed from the API but the server is still sending it.

On this, I unfortunately have no idea. This is a question for upstream developers.

Is it possible to ignore unrecognised API and logs them instead of throwing unhandled exceptions and killing the client?

But we are doing that already. An ExceptionThrown event is emitted when there's an exception in the Receiver loop; there are no unhandled exceptions anywhere.

(Also, I found that the exception is not even exposed anywhere, I'll create an improvement request for that matter.)

Do you suggest some other behavior?

@DamienLaw
Copy link
Author

You're right, there's no unhandled exception. I was only receiving that during debugging. It's not really an issue then. I'll proceed to close this issue. Thanks for your time looking into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants