bug: Telegram CRM contact lookup 403

Open
#281 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
64/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
graphql, python
Domain
api, backend

Research direction

Start at flexus_client_kit/integrations/fi_crm.py:87-90 in find_contact_by_platform_id and trace the call into ckit_erp.erp_table_data. Reproduce the Telegram private-message path with the logged 403, then verify the chosen handling prevents the exception from bubbling through Telegram processing.

Written by the indexing model from the issue text.

Description

bug

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
Dominant language
Python
Stars
6
Forks
2
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from smallcloudai/flexus-client-kit

All issues in smallcloudai/flexus-client-kit

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.