fix(api): return a clear not-configured status for tool and trigger discovery when Composio is unset - #5812
Conversation
…iscovery when Composio is unset
Before: on a self-hosted deployment without COMPOSIO_API_KEY set, POST
/tools/discover and POST /triggers/discover returned a bare 404 ("Provider
not found: composio"). That reads as "endpoint missing", so a self-hoster
can't tell a bug from a missing setup step.
After: the tools/triggers gateway registries now distinguish a provider this
deployment recognizes but hasn't configured (composio without
COMPOSIO_API_KEY) from a provider that genuinely doesn't exist. The former
raises a new ProviderNotConfiguredError, mapped by handle_adapter_exceptions
to 503 with a message naming the missing env var
("composio is not configured on this deployment. Set COMPOSIO_API_KEY to
enable it."). A truly unknown provider_key still 404s. Since registry.get()
is the single choke point for tools/triggers adapter lookups, the fix also
covers resolve/execute paths that hit an unconfigured provider, not just
discovery.
Fixes #5407
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Railway Preview Environment
|
Summary
On a self-hosted deployment without
COMPOSIO_API_KEYset,POST /tools/discoverandPOST /triggers/discover(and any other adapter lookup for thecomposioprovider) returned a bare 404 —"Provider not found: composio". That reads as "endpoint missing," so a self-hoster can't tell a real bug from a missing setup step.Before:
404 Not Found—{"detail": "Provider not found: composio"}After:
503 Service Unavailable—{"detail": "composio is not configured on this deployment. Set COMPOSIO_API_KEY to enable it."}A genuinely unknown
provider_key(a typo, or any value other thancomposio) still returns404— that distinction matters becauseprovideris a free-form string field on the request body, not a validated enum.Root cause
ToolsGatewayRegistry.get()/TriggersGatewayRegistry.get()raise a singleProviderNotFoundErrorfor any missing adapter, whether the key is genuinely unknown or just unconfigured (composio's adapter is only registered whenenv.composio.enabledis true). The router'shandle_adapter_exceptionsmapped that one exception straight to 404.Fix
ProviderNotConfiguredErrorto bothoss.src.core.tools.exceptionsandoss.src.core.triggers.exceptions— raised when a provider is recognized by the deployment but its adapter wasn't built due to missing config.ToolsGatewayRegistryandTriggersGatewayRegistrynow accept anunconfigured: Dict[provider_key, env_var]map.get()raisesProviderNotConfiguredErrorfor keys in that map instead of the genericProviderNotFoundError.api/entrypoints/routers.pywiresunconfigured={"composio": "COMPOSIO_API_KEY"}whenenv.composio.enabledis false.handle_adapter_exceptionsin both the tools and triggers FastAPI routers now mapsProviderNotConfiguredError→503with the env var named in the detail message, before falling back to404forProviderNotFoundError.Since
registry.get()is the single choke point every tools/triggers adapter call goes through (discovery, catalog browse, resolve, execute), this fix isn't discovery-only — any call that hits the unconfiguredcomposioprovider now gets the same clear503instead of a bare404.Testing
Added targeted unit tests for both domains:
api/oss/tests/pytest/unit/tools/test_discovery.py— router-level test assertingPOST /tools/discovermapsProviderNotConfiguredErrorto503withCOMPOSIO_API_KEYin the detail, plus registry-level tests distinguishing "known but unconfigured" from "unknown provider."api/oss/tests/pytest/unit/triggers/test_triggers_discovery.py— same coverage forPOST /triggers/discover.Ran the full
tools+triggersunit suites locally: 238 passed.ruff format --checkandruff checkclean on all touched files.Fixes #5407