fix(composio): avoid nested auth retry#1791
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughPost-OAuth retry handling is centralized into ChangesComposio post-OAuth retry refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/openhuman/composio/auth_retry.rs (1)
57-60: ⚡ Quick winLog the empty-slug rejection path.
This new validation branch bails without a grep-friendly diagnostic, so whitespace-only slugs will be harder to trace than the rest of the flow. Add a
[composio][auth_retry]debug/trace event before returning.Proposed fix
let tool = slug.trim(); if tool.is_empty() { + tracing::debug!( + target: "composio", + raw_slug_len = slug.len(), + "[composio][auth_retry] rejecting empty tool slug" + ); anyhow::bail!("composio.execute_tool: tool slug must not be empty"); }As per coding guidelines,
src/**/*.rs: "uselog/tracingatdebugortracelevel for development-oriented diagnostics on new/changed flows, including logs at entry/exit points, branch decisions, external calls, retries/timeouts, state transitions, and error handling paths".🤖 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/openhuman/composio/auth_retry.rs` around lines 57 - 60, The branch that trims and rejects an empty tool slug currently bails silently; add a tracing call before the bail so the rejection is grep-able and follows logging guidelines: in the auth_retry.rs code where slug is trimmed into let tool = slug.trim(); and before anyhow::bail!("composio.execute_tool: tool slug must not be empty"); emit a trace or debug event (e.g., tracing::debug! or tracing::trace!) with a clear tag like "[composio][auth_retry]" and include the original slug (or its whitespace-only indication) to aid debugging, then proceed to bail as before.
🤖 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.
Nitpick comments:
In `@src/openhuman/composio/auth_retry.rs`:
- Around line 57-60: The branch that trims and rejects an empty tool slug
currently bails silently; add a tracing call before the bail so the rejection is
grep-able and follows logging guidelines: in the auth_retry.rs code where slug
is trimmed into let tool = slug.trim(); and before
anyhow::bail!("composio.execute_tool: tool slug must not be empty"); emit a
trace or debug event (e.g., tracing::debug! or tracing::trace!) with a clear tag
like "[composio][auth_retry]" and include the original slug (or its
whitespace-only indication) to aid debugging, then proceed to bail as before.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 54bb7193-305a-4e5d-a508-207b047a655c
📒 Files selected for processing (4)
src/openhuman/composio/auth_retry.rssrc/openhuman/composio/auth_retry_tests.rssrc/openhuman/composio/client.rssrc/openhuman/composio/client_tests.rs
💤 Files with no reviewable changes (1)
- src/openhuman/composio/auth_retry_tests.rs
graycyrus
left a comment
There was a problem hiding this comment.
Walkthrough
Clean consolidation that collapses two parallel auth-retry paths into one. auth_retry.rs now delegates to the client's execute_tool_with_post_oauth_retry instead of reimplementing first-call → check → sleep → retry. Net reduction of 31 lines while preserving all behavior. The substring-match widening in is_post_oauth_auth_readiness_error correctly absorbs the gateway-wrapper matching that auth_retry.rs was doing independently. Tests relocated and expanded — good.
Change Summary
| File | Change type | Description |
|---|---|---|
auth_retry.rs |
Refactored | Removed standalone retry loop + RETRYABLE_AUTH_ERRORS constant; now validates input, constructs body, and delegates to client's retry method |
auth_retry_tests.rs |
Reduced | Removed unit tests for deleted is_retryable_auth_error; integration tests preserved |
client.rs |
Modified | execute_tool_with_post_oauth_retry widened to pub(super); is_post_oauth_auth_readiness_error changed from exact to substring match |
client_tests.rs |
Expanded | Added post_oauth_auth_readiness_error_matches_known_gateway_variants and rejection tests covering wrapped messages + successful-response edge case |
Per-file analysis
auth_retry.rs
The rewrite correctly mirrors the body construction in execute_tool (line 166 of client.rs): trim → empty check → unwrap args → json!({ "tool", "arguments" }). The 8s backoff from RETRY_BACKOFF is passed through instead of the client's default 10s — intentional per issue #1688.
client.rs
pub(super) visibility is the right scope — only auth_retry.rs (same module) needs access. The exact→substring match change is safe: "connection error, try to authenticate" is specific enough that false positives are negligible, and it now handles the gateway wrapper text that was previously only caught by auth_retry.rs.
Tests
Coverage is equivalent or better. The new client_tests.rs tests cover case-insensitive matching, wrapped gateway messages, unrelated errors, and the successful: true edge case (should not retry). The mock-server integration tests in auth_retry_tests.rs are preserved.
Overall: well-scoped refactor, no concerns beyond a minor readability nit.
# Conflicts: # src/openhuman/composio/auth_retry.rs
Co-authored-by: honor2030 <19909783+honor2030@users.noreply.github.com> Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
Summary
execute_tool_with_post_oauth_retrytest-visible and preserve gateway error matching for wrapped/case-variedConnection error, try to authenticatepayloads.Test Plan
RUSTC=$(rustup which --toolchain 1.93.0 rustc) $(rustup which --toolchain 1.93.0 cargo) fmt --allRUSTC=$(rustup which --toolchain 1.93.0 rustc) $(rustup which --toolchain 1.93.0 cargo) test --manifest-path Cargo.toml -p openhuman openhuman::composio::auth_retry -- --nocaptureRUSTC=$(rustup which --toolchain 1.93.0 rustc) $(rustup which --toolchain 1.93.0 cargo) test --manifest-path Cargo.toml -p openhuman openhuman::composio::client -- --nocaptureRUSTC=$(rustup which --toolchain 1.93.0 rustc) $(rustup which --toolchain 1.93.0 cargo) test --manifest-path Cargo.toml -p openhuman openhuman::composio -- --nocaptureSummary by CodeRabbit
Bug Fixes
Documentation
Tests