When Embedding tweet sometimes get Unexpected exception

Every few weeks, when I try to embed a tweet in an RTE using the built-in Embed function, it fails, no matter which tweet I choose, with an “Unexpected exception happened while trying to get oembed markup” error. I am using the TinyMCE package on my v16 install, so I don’t know if this is a core issue, a package issue, or a Twitter issue, and how to deal with it. Does anyone have any ideas? Here is the error stack

System.Text.Json.JsonException: 'e' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.

 ---> System.Text.Json.JsonReaderException: 'e' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.

   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)

   at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)

   at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)

   at System.Text.Json.Utf8JsonReader.ReadSingleSegment()

   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)

   --- End of inner exception stack trace ---

   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)

   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)

   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)

   at Umbraco.Cms.Infrastructure.Serialization.SystemTextJsonSerializerBase.Deserialize[T](String input)

   at Umbraco.Cms.Core.Media.EmbedProviders.OEmbedProviderBase.GetJsonResponseAsync[T](String url, CancellationToken cancellationToken)

   at Umbraco.Cms.Core.Media.EmbedProviders.OEmbedProviderBase.GetJsonBasedMarkupAsync(String url, Nullable`1 maxWidth, Nullable`1 maxHeight, CancellationToken cancellationToken)

   at Umbraco.Cms.Core.Media.EmbedProviders.X.GetMarkupAsync(String url, Nullable`1 maxWidth, Nullable`1 maxHeight, CancellationToken cancellationToken)

   at Umbraco.Cms.Core.Services.OEmbedService.GetMarkupAsync(Uri url, Nullable`1 maxWidth, Nullable`1 maxHeight, CancellationToken cancellationToken)

Does anyone have any ideas on this? When it breaks it litterly stops work for the day. It will fix it’s self by the next day but losing a day of work because of the problem is costly

Hi Matthew, sorry I didn’t see this. Would it be possible to post an issue on the package issue tracker here?

I can take a look and see if I can reproduce it or figure out what is going on here

Thanks,
Jason

Hi Jason,

I ended up opening a bug report on the CMS github page and they found it was a bug in the twitter embed provider which they have fixed so I am all set but thank you.

Thanks! Could you link me to the issue?

Sure, here is the GitHub issue.

1 Like