Skip to content

EditMessageText fails with .result: Missing required field #506

@makkarpov

Description

@makkarpov

Subject line speaks it all, Circe decoder fails to parse a Telegram server response as the Message class.

Caused by: io.circe.DecodingFailure$DecodingFailureImpl: DecodingFailure at .result: Missing required field

Library version: 6.0.0

Offending response JSON
{
  "ok": true,
  "result": {
    "message_id": 5555,
    "from": {
      "id": 111111,
      "is_bot": true,
      "first_name": "Bot name",
      "username": "bot_username"
    },
    "chat": {
      "id": 222222,
      "first_name": "First",
      "last_name": "Last",
      "username": "username",
      "type": "private"
    },
    "date": 1763154244,
    "edit_date": 1763154257,
    "text": "Message text message text message text",
    "entities": [
      {
        "offset": 18,
        "length": 11,
        "type": "bold"
      },
      {
        "offset": 31,
        "length": 16,
        "type": "bold"
      }
    ],
    "reply_markup": {
      "inline_keyboard": [
        [
          {
            "text": "opt1",
            "callback_data": "dialog/942ffa64-692c-4680-ba0a-9ada8288ff40/adj:0"
          },
          {
            "text": "opt2",
            "callback_data": "dialog/942ffa64-692c-4680-ba0a-9ada8288ff40/adj:1"
          },
          {
            "text": "opt3",
            "callback_data": "dialog/942ffa64-692c-4680-ba0a-9ada8288ff40/adj:2"
          }
        ],
        [
          {
            "text": "opt4",
            "callback_data": "dialog/942ffa64-692c-4680-ba0a-9ada8288ff40/a"
          },
          {
            "text": "opt5",
            "callback_data": "dialog/942ffa64-692c-4680-ba0a-9ada8288ff40/b"
          },
          {
            "text": "opt6",
            "callback_data": "dialog/942ffa64-692c-4680-ba0a-9ada8288ff40/c"
          }
        ]
      ]
    }
  }
}

The Message class itself is pretty weird. Decoder uses camel case fields all over the place, even though both encoder and Telegram API itself are using snake case. Yet it somehow works in other parts of the project, failing only in EditMessageText.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions