From 19913dfdd91dbfc674eed8d4f5ccae6ad6fd3456 Mon Sep 17 00:00:00 2001 From: spalen0 Date: Wed, 23 Sep 2026 08:07:55 +0000 Subject: [PATCH] fix(unibtc): drop underscore from alert label that broke Telegram Markdown 'API total_supply:' in the feeder-gap and PoR-coverage alerts is invalid Markdown V1, so Telegram rejected it and the message was resent as plain text (literal asterisks), as seen on the 2026-09-23 08:05 feeder alert. Co-Authored-By: Claude Opus 5.5 --- protocols/unibtc/main.py | 4 ++-- tests/test_unibtc.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/protocols/unibtc/main.py b/protocols/unibtc/main.py index cb846873..c618f6b4 100644 --- a/protocols/unibtc/main.py +++ b/protocols/unibtc/main.py @@ -895,7 +895,7 @@ def check_por_coverage(state: UnibtcState, api_total_supply: Decimal | None) -> f"PoR / API supply = {ratio:.4%} " f"(CRITICAL < {POR_CRITICAL_RATIO:.0%}, HIGH < {POR_HIGH_RATIO:.0%})\n" f"Chainlink PoR: {format_decimal_amount(reserves)} BTC\n" - f"API total_supply: {format_decimal_amount(api_total_supply)} uniBTC\n" + f"API total supply: {format_decimal_amount(api_total_supply)} uniBTC\n" f"🔗 PoR {_etherscan(POR_FEED)}" ) _alert_on_band_escalation( @@ -1000,7 +1000,7 @@ def check_feeder_gap(state: UnibtcState, api: ApiStats) -> None: f"total supply (threshold {FEEDER_GAP_THRESHOLD:.0%}).\n" f"{hint}" f"Feeder totalTokenSupply: {_fmt_btc(state.feeder_supply)} uniBTC\n" - f"API total_supply: {format_decimal_amount(api.total_supply)} uniBTC\n" + f"API total supply: {format_decimal_amount(api.total_supply)} uniBTC\n" f"🔗 Feeder {_etherscan(SUPPLY_FEEDER)}" ) _alert_while_true(CACHE_KEY_FEEDER_GAP, wrong, Alert(AlertSeverity.HIGH, message, PROTOCOL)) diff --git a/tests/test_unibtc.py b/tests/test_unibtc.py index 947206db..92b058ab 100644 --- a/tests/test_unibtc.py +++ b/tests/test_unibtc.py @@ -1152,3 +1152,18 @@ def test_main_withholds_rejected_api_from_checks(monkeypatch: pytest.MonkeyPatch assert received["por_supply"] is None assert received["feeder_api"] is None + + +def test_feeder_gap_alert_is_valid_markdown(monkeypatch: pytest.MonkeyPatch) -> None: + """A bare ``_`` (e.g. ``total_supply``) breaks Telegram Markdown V1 and forces a plain-text resend.""" + alerts: list[Alert] = [] + stub_cache(monkeypatch) + monkeypatch.setattr(unibtc, "send_alert", alerts.append) + + unibtc.check_supply_feeder(make_state(feeder_supply=384_533_051_367), make_api()) + unibtc.check_por_coverage(make_state(por_answer=4_000 * 10**18), make_api().total_supply) + + assert len(alerts) == 2 + for alert in alerts: + text = alert.message.replace("etherscan.io/address/", "") + assert "_" not in text.split("🔗")[0]