Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
fix(python): match the trigger toolkit filter for underscore toolkit slugs (#4954)
## Summary Python side of #4947, the follow-up I offered in #4948 (TypeScript). `@subscription.handle(toolkit="one_drive")` never calls the callback. V3 trigger frames don't carry a toolkit slug, so `_build_trigger_event_from_v3` takes the first `_` segment of the trigger slug: `ONE_DRIVE_FILE_CREATED_TRIGGER` gives `ONE`. `_filters_match` then compares `one_drive` with `one` and skips the event. That covers `one_drive` (9 triggers), `launch_darkly` (16) and `agent_mail` (1), so 26 of the 671 triggers in `docs/public/data/toolkits.json`. Fixes #4947 Designated PR reviewer: @jkomyno ## Changes - `_filters_match`: the `toolkit` filter still matches when it equals the derived `toolkit_slug`, and now also when the trigger slug starts with `<toolkit>_`, case-insensitively. Same rule as #4948. An empty filter value doesn't take the prefix path, so the existing "empty never matches" behaviour is unchanged. - Three tests in `tests/test_triggers.py` that go through `_parse_payload` with a real V3 frame: `one_drive` and `ONE_DRIVE` both match a `ONE_DRIVE_FILE_CREATED_TRIGGER` event, and `one_drive` does not match `ONE_DRIVEX_FILE_CREATED`. Like the TS PR, I left the derived `toolkit_slug` on the event alone (it is still `ONE`). Getting that right needs the toolkit slug from the backend, since it isn't in the V3 metadata. No changeset: `.changeset` only covers the TS packages, and I didn't see a per-change changelog for the Python package (`python/docs/release.md` bumps versions at release time). Happy to add one if there's somewhere it should go. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactor/Chore - [ ] Documentation - [ ] Breaking change ## How Has This Been Tested? - New tests without the fix: `pytest tests/test_triggers.py` gives 2 failed, 130 passed (`assert False is True`, the event's `toolkit_slug` is `'ONE'`). - With the fix: 132 passed in `tests/test_triggers.py`, and 187 passed across `test_triggers.py`, `test_webhooks.py` and `test_verify_webhook_integration.py`. - Full `pytest tests` (minus `test_provider.py`, providers not installed): 2292 passed. The 8 failures and 4 errors are in `test_cross_sdk_compatibility.py` (needs the `ts/` fixtures, which weren't in my sparse checkout), `test_schema_semantic_regressions.py` and `test_url_safety_pinning.py` (local sockets blocked in my environment). They fail the same way on `next` without this change. - `ruff --config config/ruff.toml check composio/ tests/`: clean. `ruff format --check` on the two files: clean. - `mypy --config-file config/mypy.ini composio/ tests/test_triggers.py`: no issues in 64 files. Python 3.12.12, ruff 0.17.1, mypy 2.3.1, pydantic 2.12.5 (from `uv.lock`). ## Screenshots (if applicable) n/a ## Checklist - [x] I have read the Code of Conduct and this PR adheres to it - [x] I have read and understand every line of this diff, including any LLM-generated code - [x] Any third-party docs links or promotional content follow the [third-party links policy](https://github.com/ComposioHQ/composio/blob/next/CONTRIBUTING.md#third-party-links-in-docs) - [x] I ran linters/tests locally and they passed - [x] I updated documentation as needed - [x] I added tests or explain why not applicable - [ ] I added a changeset if this change affects published packages ## Additional context Every trigger slug in `toolkits.json` starts with `<TOOLKIT>_`, which is what the prefix match relies on. The `ONE_DRIVEX_` test is there so a longer slug that only shares the prefix doesn't match. --------- Co-authored-by: jkomyno <alberto@composio.dev>