Skip to content

Fix composio integrations URL base normalization#1715

Merged
senamakel merged 2 commits into
tinyhumansai:mainfrom
oxoxDev:fix/composio-url-concat
May 14, 2026
Merged

Fix composio integrations URL base normalization#1715
senamakel merged 2 commits into
tinyhumansai:mainfrom
oxoxDev:fix/composio-url-concat

Conversation

@oxoxDev
Copy link
Copy Markdown
Contributor

@oxoxDev oxoxDev commented May 14, 2026

Summary

  • Normalize integrations API override URLs to their scheme/host/port root before appending /agent-integrations/*.
  • Preserve the existing local-AI fallback for localhost/Ollama-style and third-party chat-completions endpoints.
  • Add typed config regression coverage for TinyHumans, localhost Ollama, trailing /openai/v1/, and OpenRouter URL shapes.

Problem

Solution

  • Parse non-local integration overrides with url::Url and strip path/query/fragment down to scheme://host[:port].
  • Keep malformed URL behavior on the existing trim/normalize fallback.
  • Leave local-AI detection first so localhost/Ollama and third-party chat endpoints still fall back to env/default backend.

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
  • N/A: Diff coverage >= 80% -- full diff-cover was not run locally for this one-file Rust fix; changed behavior is covered by focused unit tests.
  • N/A: Coverage matrix updated -- no feature rows were added, removed, or renamed.
  • N/A: All affected feature IDs from the matrix are listed in the PR description under ## Related -- no coverage-matrix feature IDs changed.
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • N/A: Manual smoke checklist updated -- no release-cut manual smoke surface changed.
  • N/A: Linked issue closed via Closes #NNN in the ## Related section -- no GitHub issue number; Sentry IDs are listed below with closing keywords.

Impact

  • Desktop/core integration requests now resolve TinyHumans-hosted LLM proxy configs to the hosted API root before Composio paths are appended.
  • Local AI endpoints continue to fall back to the hosted integrations base instead of hitting local LLM servers.
  • No migration, security, or performance impact beyond URL normalization.

Related

  • Closes OPENHUMAN-TAURI-FJ
  • Closes OPENHUMAN-TAURI-FM
  • Closes OPENHUMAN-TAURI-BX

Summary by CodeRabbit

  • Bug Fixes
    • Fixed API URL handling to prevent LLM endpoint paths from interfering with agent integrations operations. Configured URLs are now properly normalized to extract the host root, ensuring integrations work reliably regardless of base API URL configuration.

Review Change Stack

@oxoxDev oxoxDev requested a review from a team May 14, 2026 08:30
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

📝 Walkthrough

Walkthrough

effective_integrations_api_url is updated to normalize user-overridden api_url values by stripping path, query, and fragment segments. A new helper function ensures integrations always start from the host root. Test infrastructure is refactored to snapshot environment variables deterministically, with expanded coverage for LLM-endpoint override scenarios.

Changes

Integrations URL normalization

Layer / File(s) Summary
Integrations URL normalization and integration point
src/api/config.rs
New normalize_integrations_api_base_url function strips path/query/fragment to ensure host-root URLs. effective_integrations_api_url now uses this normalizer instead of simple URL trimming, preventing embedded LLM/chat-completion paths from leaking into integrations calls.
Test infrastructure and validation
src/api/config.rs
EnvSnapshot helper captures, clears, and restores key environment variables automatically on drop. New table-driven test integrations_url_handles_llm_endpoint_overrides validates the normalizer handles multiple api_url override patterns including OpenAI-path variants and local-AI-like endpoints.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • tinyhumansai/openhuman#1630: Updates effective_integrations_api_url handling of api_url overrides to strip path/query/fragment and return the integrations host root, preventing local-AI URL path leakage.
  • tinyhumansai/openhuman#1650: Both PRs address misconfigured API base URLs in src/api/config.rs to prevent paths from corrupting integration request routes—main PR fixes effective_integrations_api_url normalization while the other introduces safe api_url joining.

Poem

🐰 A path was lost in the URLs deep,
Chat endpoints in integrations would creep!
Now hosts stand bare, stripped to the root,
LLM trails trim'd—a tidy rebuke,
With snapshots to test, the tests leap! 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing URL normalization for Composio integrations to strip paths from configured API URLs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 lift

Hosted /openai/v1/chat/completions overrides still miss the normalization path.

looks_like_local_ai_endpoint() runs before normalize_integrations_api_base_url(), and its path-only match treats any host ending in /v1/chat/completions as local-AI. So overrides like https://staging-api.tinyhumans.ai/openai/v1/chat/completions or a self-hosted backend proxy will still fall through to env/default instead of normalizing to their own host root. The new https://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 win

Add 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/trace logs 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 "use log / tracing at debug or trace level 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d34262c3-7d5a-4660-aafa-09ec21d80121

📥 Commits

Reviewing files that changed from the base of the PR and between 2672706 and 7b0d93d.

📒 Files selected for processing (1)
  • src/api/config.rs

@Kacpertrojnar72
Copy link
Copy Markdown

Kacpertrojnar72 commented May 14, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants