Skip to content

bug: Telegram CRM contact lookup 403 #281

@flexus-teams

Description

@flexus-teams

Original Logs

20260402 06:42:24.232 bot_karen [INFO] FyTqvLzXC2 Telegram private by @Oleg Klimov: hi
20260402 06:42:24.262 btexe [ERROR] 🛑 FyTqvLzXC2 error in on_emessage('TELEGRAM') handler: TransportQueryError
{'message': '403: you have nothing, this operation requires R', 'locations': [{'line': 2, 'column': 3}], 'path': ['erp_table_data']}

Error Summary

Karen bot hits an unhandled GraphQL 403 when looking up a Telegram contact by platform id during every Telegram private message processing path.

Stacktrace

/app/flexus_client_kit/ckit_bot_exec.py -> unpark_collected_events
/app/flexus_client_kit/ckit_integrations_db.py -> _emessage_handler
/app/flexus_client_kit/integrations/fi_telegram.py -> handle_emessage
/app/flexus_simple_bots/karen/karen_bot.py -> telegram_activity_callback
/app/flexus_client_kit/integrations/fi_crm.py -> find_contact_by_platform_id
/app/flexus_client_kit/ckit_erp.py -> erp_table_data

Root Cause

  • File: flexus_client_kit/integrations/fi_crm.py:87-90
  • Function: find_contact_by_platform_id
  • Why: It queries crm_contact via erp_table_data using the current bot HTTP context. In this deployment the bot only has insufficient ERP permissions, so the GraphQL call fails with 403 instead of returning no contact. The exception bubbles up through Telegram handling.
  • Git blame: @oleg Klimov in 34ba22a (2026-03-31)

Code Snippet

async def find_contact_by_platform_id(http, ws_id: str, platform: str, identifier: str) -> Optional[str]:
    contacts = await ckit_erp.erp_table_data(
        http, "crm_contact", ws_id, erp_schema.CrmContact,
        filters=f"contact_platform_ids->{platform}:=:{identifier}", limit=1,
    )
    return contacts[0].contact_id if contacts else None

Affected

  • Pods: flexus-pod-bot-karen-100020170-rx
  • Namespaces: isolated
  • Occurrences: 1 observed, likely repeatable for Telegram private messages

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions