Fix composio integrations URL base normalization#1715
Conversation
📝 WalkthroughWalkthrough
ChangesIntegrations URL normalization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/api/config.rs (2)
169-175:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy liftHosted
/openai/v1/chat/completionsoverrides still miss the normalization path.
looks_like_local_ai_endpoint()runs beforenormalize_integrations_api_base_url(), and its path-only match treats any host ending in/v1/chat/completionsas local-AI. So overrides likehttps://staging-api.tinyhumans.ai/openai/v1/chat/completionsor a self-hosted backend proxy will still fall through to env/default instead of normalizing to their own host root. The newhttps://api.tinyhumans.ai/...case passes only because the default backend happens to equal the expected value in this test setup.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/api/config.rs` around lines 169 - 175, The override path skips normalization because looks_like_local_ai_endpoint(u) runs on the raw user string; to fix, first normalize the user-provided api_url (use normalize_integrations_api_base_url on u) and then run looks_like_local_ai_endpoint against that normalized value; if the normalized URL is detected as a local-AI endpoint call warn_integrations_url_fallback_once(normalized) and fall through to env/default, otherwise return the normalized base URL. Ensure you reference the same variables (api_url, u) and functions (normalize_integrations_api_base_url, looks_like_local_ai_endpoint, warn_integrations_url_fallback_once) when making the change.
168-201: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winAdd debug diagnostics for the new integrations normalization flow.
This adds a new branch and URL rewrite, but the successful normalization path is silent. Please emit
debug/tracelogs with a stable[api/config]prefix for the branch decision and normalized host/root, while redacting any sensitive URL parts. As per coding guidelines,src/**/*.rs: "All new/changed behavior in Rust core must include verbose diagnostics logging with stable grep-friendly prefixes like[domain],[rpc]and correlation fields" and "uselog/tracingatdebugortracelevel for development-oriented diagnostics on new/changed flows."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/api/config.rs` around lines 168 - 201, Add trace/debug diagnostics for the integrations URL normalization flow: inside effective_integrations_api_url log a stable "[api/config]" prefixed message indicating which branch was taken (used user override -> normalized, rejected as local AI endpoint -> fallback, env override used, or default selected) and include a correlation field if available; inside normalize_integrations_api_base_url emit a "[api/config]" debug/trace message showing the normalized host/root returned. Ensure logs redact sensitive parts by removing userinfo, query and fragment and only include scheme://host[:port]/ (or just host[:port] if you prefer) so no credentials or query strings are printed; reference the functions effective_integrations_api_url and normalize_integrations_api_base_url and the predicate looks_like_local_ai_endpoint when adding these messages.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/api/config.rs`:
- Around line 169-175: The override path skips normalization because
looks_like_local_ai_endpoint(u) runs on the raw user string; to fix, first
normalize the user-provided api_url (use normalize_integrations_api_base_url on
u) and then run looks_like_local_ai_endpoint against that normalized value; if
the normalized URL is detected as a local-AI endpoint call
warn_integrations_url_fallback_once(normalized) and fall through to env/default,
otherwise return the normalized base URL. Ensure you reference the same
variables (api_url, u) and functions (normalize_integrations_api_base_url,
looks_like_local_ai_endpoint, warn_integrations_url_fallback_once) when making
the change.
- Around line 168-201: Add trace/debug diagnostics for the integrations URL
normalization flow: inside effective_integrations_api_url log a stable
"[api/config]" prefixed message indicating which branch was taken (used user
override -> normalized, rejected as local AI endpoint -> fallback, env override
used, or default selected) and include a correlation field if available; inside
normalize_integrations_api_base_url emit a "[api/config]" debug/trace message
showing the normalized host/root returned. Ensure logs redact sensitive parts by
removing userinfo, query and fragment and only include scheme://host[:port]/ (or
just host[:port] if you prefer) so no credentials or query strings are printed;
reference the functions effective_integrations_api_url and
normalize_integrations_api_base_url and the predicate
looks_like_local_ai_endpoint when adding these messages.
|
Pozwany jestes?
|
Summary
/agent-integrations/*./openai/v1/, and OpenRouter URL shapes.Problem
config.api_urlcan contain an inference endpoint likehttps://api.tinyhumans.ai/openai/v1/chat/completions./agent-integrations/..., producing concatenated 404 URLs.Solution
url::Urland strip path/query/fragment down toscheme://host[:port].Submission Checklist
## Related-- no coverage-matrix feature IDs changed.Closes #NNNin the## Relatedsection -- no GitHub issue number; Sentry IDs are listed below with closing keywords.Impact
Related
Summary by CodeRabbit