Skip to content

fix(auth): actionable cloud-runtime sign-in failure message + docs (#3025) - #4649

Merged
senamakel merged 2 commits into
tinyhumansai:mainfrom
M3gA-Mind:fix/3025-cloud-signin-actionable-error
Jul 7, 2026
Merged

senamakel merged 2 commits into
tinyhumansai:mainfrom
M3gA-Mind:fix/3025-cloud-signin-actionable-error

Conversation

@M3gA-Mind

@M3gA-Mind M3gA-Mind commented Jul 7, 2026 •

Copy link
Copy Markdown
Collaborator

Symptom

On a cloud / self-hosted runtime, OAuth (Google/GitHub/Twitter) completes in the browser ("close this and return to the app"), but the desktop then shows "Sign-in failed. Please try again." — while the same account signs in fine on the local embedded runtime (#3025).

Investigation — no reproducible desktop bug

auth_store_session makes the core validate the freshly minted session token against the backend GET /auth/me before persisting it (the team's own documented hypothesis, pinned in desktopDeepLinkListener.test.ts). In cloud mode that validation runs on the user's remote openhuman-core, so the dominant failure is the remote runtime being unable to reach/authenticate the backend:

  • BACKEND_URL unset/wrong on the server — a reporter in the thread confirmed their fix was "missed certain default settings from the env."
  • backend unreachable from the server (egress/DNS/TLS) → gateway/timeout on /auth/me
  • an outdated core that predates allowPendingBackendValidation (validates synchronously)
  • wrong RPC token → HTTP 401 on /rpc

The desktop transport is correct: getCoreRpcUrl/getCoreRpcToken prefer the stored cloud URL/token, the RPC caches are busted before session delivery (applySessionToken), and HTTPS cores are fetched directly (the reporter's "Test Connection" passed). So the desktop can't retry away the failure — but it was hiding the real cause behind a dead-end generic message.

Change (safe, verifiable)

  • Add authStoreFailureUserMessage(kind, mode): in cloud mode, replace the generic message with an actionable one pointing at the remote runtime — token/backend hint for 401, connectivity/BACKEND_URL hint for gateway/timeout/network, and a general "verify it's running & configured" fallback. Local/unset mode keeps the existing plain retry message.
  • Wire it into the deep-link auth-store catch path (no change to auth flow behavior).
  • Document the failure mode and its remote-core causes in gitbooks/features/cloud-deploy.md.

Tests

Unit coverage for the message selector: local/unset stays generic (existing assertions unaffected — they run with mode unset), cloud is actionable and mode/kind-specific.

Scope

This makes the cloud-mode failure diagnosable and actionable and documents the setup requirement; it does not claim to make a misconfigured/offline remote core validate sessions (that's a server-side config/version concern). Hence Refs #3025 rather than Closes — recommend keeping the issue open until the docs + message land and confirm the remaining reports are remote-core config.

Validation note

Per request, no tests were run locally — CI is authoritative. (The full Rust/cargo build is also blocked in my environment by a proxy TLS error on the CEF download.)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Improved sign-in failure messages for cloud-based desktop login, with clearer, mode-specific guidance when remote connection or configuration issues are detected.
  • Bug Fixes

    • Kept the existing generic retry message for local sign-in failures, while showing more helpful cloud-specific hints for remote auth problems.
  • Documentation

    • Added troubleshooting guidance for cloud sign-in failures after OAuth, including common causes and what to check next.

…inyhumansai#3025)

On a cloud/self-hosted runtime, OAuth sign-in can complete in the browser yet
the desktop shows "Sign-in failed. Please try again." with no guidance, while
the same account signs in fine on the local runtime (tinyhumansai#3025).

Investigation (no reproducible desktop bug): `auth_store_session` makes the core
validate the fresh session token against the backend `GET /auth/me` before
persisting. In cloud mode that runs on the user's *remote* core, so the failure
is the remote runtime being unable to reach/authenticate the backend
(misconfigured `BACKEND_URL`, offline, or a core predating
`allowPendingBackendValidation`) — confirmed by a reporter whose fix was missing
env settings. The desktop-side transport is correct: URL/token resolution
prefers the stored cloud values and the RPC caches are busted before delivery.

Change (safe, verifiable):
- Add `authStoreFailureUserMessage(kind, mode)`: in cloud mode, replace the
  dead-end generic message with a message pointing at the remote runtime —
  token/backend hint for 401, connectivity/`BACKEND_URL` hint for
  gateway/timeout/network. Local/unset mode keeps the plain retry message.
- Wire it into the deep-link auth-store catch path.
- Document the failure and its remote-core causes in the cloud-deploy guide.

Tests: unit coverage for the new message selector (local/unset stays generic;
cloud is actionable and mode/kind-specific). Existing generic-message tests run
with mode unset and are unaffected.

Refs tinyhumansai#3025

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@M3gA-Mind
M3gA-Mind requested a review from a team July 7, 2026 14:18
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an exported authStoreFailureUserMessage(kind, mode) helper in the desktop deep-link listener that produces mode-aware sign-in failure messages, wires it into the login error handler for cloud mode, adds corresponding tests, and adds troubleshooting documentation in the cloud-deploy guide.

Changes

Cloud-aware auth failure message

Layer / File(s) Summary
Helper implementation and wiring
app/src/utils/desktopDeepLinkListener.ts
Adds exported authStoreFailureUserMessage(kind, mode) returning generic text for non-cloud modes and kind-specific remote/backend guidance for cloud mode; wires it into the login error handler replacing the previous hardcoded generic message.
Tests and troubleshooting docs
app/src/utils/__tests__/desktopDeepLinkListener.test.ts, gitbooks/features/cloud-deploy.md
Adds a test suite verifying message output across local/null/cloud modes and failure kinds, and documents troubleshooting steps for OAuth sign-in failures on cloud runtimes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DeepLinkListener
  participant AuthStoreFailureUserMessage
  participant User

  DeepLinkListener->>DeepLinkListener: classify failure kind
  DeepLinkListener->>AuthStoreFailureUserMessage: authStoreFailureUserMessage(kind, mode)
  alt mode is cloud
    AuthStoreFailureUserMessage-->>DeepLinkListener: kind-specific remote guidance
  else mode is local or null
    AuthStoreFailureUserMessage-->>DeepLinkListener: generic retry message
  end
  DeepLinkListener->>User: failDeepLinkAuthProcessing(message)
Loading

Poem

A rabbit hopped through logs so deep,
Found "BACKEND_URL" the auth couldn't keep 🐰
Now cloud users get hints, not just despair,
"Check your RPC token" — clear and fair,
Docs and tests in tidy rows,
This bunny's burrow of fixes grows! 🥕

🚥 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 accurately summarizes the main change: a clearer cloud-runtime sign-in failure message plus documentation updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

…nyhumansai#3025)

CI Frontend Checks flagged prettier formatting: hoist the shared kind list to a
CLOUD_KINDS const (avoids the >100-col inline array) and trim two it() titles.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (2)
app/src/utils/desktopDeepLinkListener.ts (2)

288-288: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider logging the resolved mode for correlation.

console.warn at Line 287 logs kind but not the mode used to pick the message. Since the message text now branches heavily on mode, logging it alongside kind would help correlate cloud vs local failures in Sentry/console without extra effort.

As per coding guidelines, "On new or changed flows, add verbose debug logging with stable prefixes, correlation fields, and no secrets or full PII; incomplete changes are those lacking logging."

🤖 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 `@app/src/utils/desktopDeepLinkListener.ts` at line 288, The deep-link auth
failure logging in desktopDeepLinkListener should include the resolved mode used
to choose the user-facing message, since the current warning only records kind.
Update the existing console.warn/failure path around failDeepLinkAuthProcessing
and authStoreFailureUserMessage to log both kind and the resolved
getStoredCoreMode() result with a stable prefix, so cloud vs local failures can
be correlated in Sentry/console without exposing secrets or PII.

Source: Coding guidelines


337-364: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

New user-facing strings bypass useT().

The new hardcoded English strings returned by authStoreFailureUserMessage are surfaced directly to users via failDeepLinkAuthProcessing, but this file already had this pattern pre-existing (e.g., Lines 193, 205, 262-267) prior to this change, so this is consistent with the file's established (non-i18n) convention rather than a net-new deviation. Flagging for awareness since the guideline requires all UI text go through useT() with keys added to en.ts and all locale files.

As per coding guidelines, "All UI text must go through useT() from app/src/lib/i18n/I18nContext, and new keys must be added to en.ts plus all locale files."

🤖 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 `@app/src/utils/desktopDeepLinkListener.ts` around lines 337 - 364, The
user-facing failure messages in authStoreFailureUserMessage are hardcoded
English and should be routed through useT() instead of returning raw strings.
Update authStoreFailureUserMessage and the call path in
failDeepLinkAuthProcessing to fetch localized strings via i18n keys, then add
the new keys to en.ts and every locale file so all surfaced deep-link auth
errors are translated consistently.

Source: Coding guidelines

🤖 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 `@app/src/utils/desktopDeepLinkListener.ts`:
- Line 288: The deep-link auth failure logging in desktopDeepLinkListener should
include the resolved mode used to choose the user-facing message, since the
current warning only records kind. Update the existing console.warn/failure path
around failDeepLinkAuthProcessing and authStoreFailureUserMessage to log both
kind and the resolved getStoredCoreMode() result with a stable prefix, so cloud
vs local failures can be correlated in Sentry/console without exposing secrets
or PII.
- Around line 337-364: The user-facing failure messages in
authStoreFailureUserMessage are hardcoded English and should be routed through
useT() instead of returning raw strings. Update authStoreFailureUserMessage and
the call path in failDeepLinkAuthProcessing to fetch localized strings via i18n
keys, then add the new keys to en.ts and every locale file so all surfaced
deep-link auth errors are translated consistently.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 10acc28b-adb5-4958-9998-17ce90c45208

📥 Commits

Reviewing files that changed from the base of the PR and between 0663750 and fdbec4a.

📒 Files selected for processing (3)
  • app/src/utils/__tests__/desktopDeepLinkListener.test.ts
  • app/src/utils/desktopDeepLinkListener.ts
  • gitbooks/features/cloud-deploy.md

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