oncall-engine/engine/apps/telegram
Joey Orlando 0c96427cfc
fix apps.telegram.tasks.send_log_and_actions_message retrying tasks (#4851)
# What this PR does

It _appears_ like Telegram may have changed one of the error messages
they return for `telegram.error.BadRequest`. This _may_ be causing us to
infinitely retry some of these tasks.

Previously we were checking for two variants of the same type of error
message:
- "Message to reply not found"
- "Replied message not found"

_However_, if I search for the following [in the
logs](https://ops.grafana-ops.net/goto/hMgBb8CSR?orgId=1):
```logql
{namespace="amixr-prod"} |~ `(Message to be replied not found|Message to reply not found|Replied message not found)`
````
I _only_ see references to "Message to be replied not found". I have
updated references to the former to this new error log message we are
seeing.

Also:
- deduplicate some of the words we check for in
`telegram.error.BadRequest` and `telegram.error.Unauthorized` into
`apps.telegram.client.TelegramClient.BadRequestMessage` and
`apps.telegram.client.TelegramClient.UnauthorizedMessage` respectively
- deduplicate some of the wording we use in the `reason` arg passed to
`TelegramToUserConnector.create_telegram_notification_error` into
`apps.telegram.models.connectors.personal.TelegramToUserConnector.NotificationErrorReason`
- standardize how we check the `message` attribute of
`telegram.error.TelegramError`s into a new `error_message_is` static
method on `apps.telegram.client.TelegramClient`
- previously we would check these error messages in two different ways:
  ```python3
  # style 1
  if "error message to check" in e.message:
    # do something

  # style 2
  if error.message == "error message to check":
    # do something
  ```

## Which issue(s) this PR closes

Closes https://github.com/grafana/oncall-private/issues/2868

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-08-19 14:05:40 -04:00
..
migrations Add database migrations linter (#1020) 2023-02-06 16:01:37 +08:00
models fix apps.telegram.tasks.send_log_and_actions_message retrying tasks (#4851) 2024-08-19 14:05:40 -04:00
renderers add mypy static type checker to backend codebase (#2151) 2023-06-12 12:50:33 -04:00
tests fix apps.telegram.tasks.send_log_and_actions_message retrying tasks (#4851) 2024-08-19 14:05:40 -04:00
updates Update alert group state by backsync (#4089) 2024-03-27 12:37:01 +00:00
__init__.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
alert_group_representative.py Add transaction on_commit before signals for alert group actions (#3731) 2024-01-31 15:54:50 -07:00
apps.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
client.py fix apps.telegram.tasks.send_log_and_actions_message retrying tasks (#4851) 2024-08-19 14:05:40 -04:00
decorators.py fix apps.telegram.tasks.send_log_and_actions_message retrying tasks (#4851) 2024-08-19 14:05:40 -04:00
exceptions.py Handle ag telegram message does not exist (#3830) 2024-02-05 12:19:41 +00:00
signals.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
tasks.py fix apps.telegram.tasks.send_log_and_actions_message retrying tasks (#4851) 2024-08-19 14:05:40 -04:00
urls.py Slack and telegram routes to test chatops-proxy v3 (#3723) 2024-01-22 13:48:19 +08:00
utils.py Introduce org uuid (#947) 2022-12-06 22:42:58 +08:00
views.py Fix SQLite permission issue (#1984) 2023-05-22 19:16:31 +00:00