Hello, got this bug
Bug: RichText cannot deserialize Bot API string/array wire forms — breaks getUpdates and rich editMessageText responses
Library: telegrambots-meta 10.1.0
API: Bot API 10.1 Rich Messages
Summary
Per Bot API RichText, a RichText value can be:
- a plain JSON string,
- a JSON array of RichText, or
- a typed object with a type discriminator (bold, italic, …).
In 10.1.0, RichText is modeled only as a polymorphic interface with @JsonTypeInfo / @JsonSubTypes for typed objects. There is no support for the string or array forms. That makes Jackson fail whenever Telegram returns a full Message.rich_message tree (which almost always contains plain strings and often arrays).
Impact
1. getUpdates stalls
After the bot sends or edits a rich message, the next update that includes that message (e.g. callback_query.message with rich_message) cannot be deserialized. Long polling retries forever on the same update:
Unable to deserialize response
Caused by: com.fasterxml.jackson.databind.JsonMappingException:
text is marked non-null but is null
... Message["rich_message"]->RichMessage["blocks"]->...
RichBlockSectionHeadingBuilder["text"]
Caused by: java.lang.NullPointerException: text is marked non-null but is null
at RichBlockSectionHeading$RichBlockSectionHeadingBuilder.text(...)
Root cause: Jackson tries to bind a JSON string into RichText via AsPropertyTypeDeserializer, fails, then Lombok @NonNull on the builder rejects null.
2. editMessageText with rich_message looks like an API failure
Telegram accepts the edit and returns ok: true with a Message containing rich_message. Client-side deserialization of that Message fails (deserializeResponseMessageOrBoolean then fails on Boolean as well), so callers see Unable to deserialize response even though the edit succeeded. Same issue can affect sendRichMessage response parsing.
Minimal reproduction (incoming update)
{
"ok": true,
"result": [{
"update_id": 1,
"callback_query": {
"id": "1",
"from": { "id": 1, "is_bot": false, "first_name": "A" },
"chat_instance": "1",
"data": "x",
"message": {
"message_id": 1,
"date": 1,
"chat": { "id": 1, "type": "private" },
"rich_message": {
"blocks": [
{ "type": "heading", "size": 2, "text": "Politics" },
{
"type": "paragraph",
"text": [
"Hello ",
{ "type": "bold", "text": "world" },
"!"
]
}
]
}
}
}
}]
}
GetUpdates.deserializeResponse(...) fails on "Politics" and on the paragraph text array.
Expected behavior
Deserialize RichText like other Bot API clients (e.g. pengrad / telebot):
- JSON string → plain text node
- JSON array → sequence of RichText
- JSON object → existing typed subtypes (RichTextBold, …)
- unknown type → safe fallback (do not fail the whole update)
Suggested fix
Add a custom JsonDeserializer<RichText> (and/or RichTextPlain + RichTextArray types) and disable or replace the current @JsonTypeInfo-only model so string/array forms are first-class. Apply it on the shared PartialBotApiMethod ObjectMapper so both getUpdates and method responses are fixed.
Until then, bots that use Rich Messages cannot reliably process updates that reference those messages.
ThreadHello, got this bug
3 messages · –S Thanks for the quick fix! I verified against dev / 10.1.1 locally (built from source and installed to local Maven). After upgrading from 10.1.0: getUpdates successfully deserializes updates that include callback_query.message.rich_message with plain-string and array RichText forms sendRichMessage and editMessageText with rich_message work correctly end-to-end (no more Unable to deserialize response / text is marked non-null but is null) The previous polling stall on rich-message callback updates is gone