Skip to content

Revert "fix(kiloclaw): harden Composio onboarding"#3491

Merged
pandemicsyn merged 1 commit into
mainfrom
revert-3400-florian/fix-composio-onboarding-flow
May 26, 2026
Merged

Revert "fix(kiloclaw): harden Composio onboarding"#3491
pandemicsyn merged 1 commit into
mainfrom
revert-3400-florian/fix-composio-onboarding-flow

Conversation

@pandemicsyn
Copy link
Copy Markdown
Contributor

Reverts #3400

@pandemicsyn pandemicsyn enabled auto-merge (squash) May 26, 2026 14:03
await patchSecretsBackoff(MANAGED_COMPOSIO_PATCH_SECRETS_BACKOFF_MS[attemptIndex]);
}
}
await client.patchSecrets(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: patchSecrets errors are now unhandled — they propagate as exceptions instead of returning false

The original code caught all patchSecrets errors, logged them, and returned false cleanly. This PR removes that try/catch, so any network/5xx error from patchSecrets now throws out of completeManagedComposioGoogleCalendarConnection.

In the popup path the outer catch in the route handler does catch it, but the user receives 'internal_error' (via callbackFailureError) rather than the expected 'connection_failed'. More importantly, the DB writes for google_calendar_connected_account_id and composio_config_source are skipped, so the connection attempt is not persisted even if the Composio side succeeded.

If this is intentional (simplify the flow while the feature is disabled), the trade-off should be documented so it's not missed when re-enabling.

if (existing) return existing;

throw new Error('Failed to reserve managed Composio identity');
const [inserted] = await db
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: Removal of onConflictDoNothing relies entirely on the advisory lock preventing concurrent inserts

The old code used onConflictDoNothing + fallback findCurrentComposioIdentity as a database-level safety net for concurrent reservations. The new code replaces this with a plain INSERT ... RETURNING and relies solely on the withKiloclawProvisionContextLock acquired in ensureManagedComposioIdentity.

This is safe as long as all callers of ensureManagedComposioIdentity for the same scope hold the same lock key. However, the inner lock key (kiloclaw-composio:user:${userId}) differs from the outer router provision lock key (kiloclaw:provision:personal:${userId}). They don't share the same advisory lock integer (via hashtext), so concurrent requests serialized only by the outer lock would not be protected if they somehow bypass ensureManagedComposioIdentity's inner lock. Currently, all callers go through the inner lock, so this should be safe — but the safety net removal makes it brittle if a future caller skips ensureManagedComposioIdentity and calls createPendingComposioIdentityReservation directly.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented May 26, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Executive Summary

patchSecrets errors now propagate as unhandled exceptions in completeManagedComposioGoogleCalendarConnection, skipping DB writes that persist the connected account on failure; the advisory-lock-only insert in createPendingComposioIdentityReservation also removes the database-level uniqueness safety net.

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/kiloclaw/composio-onboarding.ts 219 patchSecrets errors now throw instead of returning false; DB writes for connected-account persistence are skipped on failure
apps/web/src/lib/kiloclaw/composio-identities.ts 196 onConflictDoNothing safety net removed; correctness now relies entirely on the advisory lock
Files Reviewed (14 files)
  • apps/web/src/app/(app)/claw/components/ClawOnboardingFlow.tsx
  • apps/web/src/app/(app)/claw/components/ConnectToolsStep.tsx
  • apps/web/src/app/(app)/claw/components/useComposioPopup.test.ts (deleted)
  • apps/web/src/app/(app)/claw/components/useComposioPopup.ts (deleted)
  • apps/web/src/app/api/integrations/composio/callback/route.ts
  • apps/web/src/app/api/integrations/composio/callback/route.test.ts
  • apps/web/src/hooks/useKiloClaw.ts
  • apps/web/src/hooks/useOrgKiloClaw.ts
  • apps/web/src/lib/kiloclaw/composio-identities.ts - 1 issue
  • apps/web/src/lib/kiloclaw/composio-onboarding.ts - 1 issue
  • apps/web/src/lib/kiloclaw/composio-onboarding.test.ts
  • apps/web/src/lib/kiloclaw/composio-identities.test.ts
  • apps/web/src/routers/kiloclaw-router.ts
  • apps/web/src/routers/organizations/organization-kiloclaw-router.ts

Fix these issues in Kilo Cloud


Reviewed by claude-4.6-sonnet-20260217 · 2,962,183 tokens

Review guidance: REVIEW.md from base branch main

@pandemicsyn pandemicsyn merged commit ad007a0 into main May 26, 2026
17 checks passed
@pandemicsyn pandemicsyn deleted the revert-3400-florian/fix-composio-onboarding-flow branch May 26, 2026 14:08
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.

2 participants