Skip to content

fix(gateway): honor browser profile from request body for node proxy calls#28852

Merged
steipete merged 2 commits intoopenclaw:mainfrom
Sid-Qin:fix/28687-browser-profile-from-body
Mar 2, 2026
Merged

fix(gateway): honor browser profile from request body for node proxy calls#28852
steipete merged 2 commits intoopenclaw:mainfrom
Sid-Qin:fix/28687-browser-profile-from-body

Conversation

@Sid-Qin
Copy link
Contributor

@Sid-Qin Sid-Qin commented Feb 27, 2026

Summary

  • Problem: Browser proxy requests in gateway only read profile from query params, so calls that pass profile in POST body silently lose it.
  • Why it matters: Explicit profile: "openclaw" can be ignored and fall back to default profile (chrome), causing wrong runtime mode and startup errors.
  • What changed: Added resolveRequestedProfile() in src/gateway/server-methods/browser.ts to resolve profile from query.profile first, then fallback to body.profile.
  • What did NOT change: Browser routing, node command policy, profile selection logic outside request parsing.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • Browser requests that pass profile in POST body now correctly honor that profile.
  • profile passed in query remains the highest-priority source.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: Linux/macOS (gateway side)
  • Runtime: Node.js
  • Integration/channel: browser tool via gateway node proxy

Steps

  1. Send a browser proxy request with POST body containing profile: "openclaw" and no query.profile.
  2. Observe node proxy receives params.

Expected

  • Node proxy receives profile: "openclaw".

Actual

  • Before fix: profile was undefined unless put in query.
  • After fix: profile resolved from body when query does not provide it.

Evidence

Type-check passed after change:

  • pnpm -C /Users/sidqin/Desktop/openclaw-contrib exec tsc --noEmit --pretty false

Core change in src/gateway/server-methods/browser.ts:

  • old: profile: typeof query?.profile === "string" ? query.profile : undefined
  • new: profile: resolveRequestedProfile({ query, body })

Human Verification (required)

  • Verified scenarios: query profile provided; body profile provided; both missing.
  • Edge cases checked: whitespace-only profile values are trimmed and treated as empty.
  • What I did not verify: Full e2e browser session against live extension relay.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Failure Recovery (if this breaks)

  • How to disable/revert: Revert this commit.
  • Files/config to restore: src/gateway/server-methods/browser.ts
  • Known bad symptoms: profile may again be ignored when only present in POST body.

Risks and Mitigations

Low risk. Change is scoped to parsing profile input and keeps query precedence unchanged.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 27, 2026

Greptile Summary

Fixes gateway browser proxy to correctly read profile parameter from POST request body when query params don't provide it. Previously, profile in request body was silently ignored, causing fallback to default profile and potential startup errors. The new resolveRequestedProfile() function maintains query param precedence while enabling body fallback, following the same pattern already used in browser/routes/utils.ts. Implementation properly handles edge cases (empty/whitespace strings are treated as undefined). Tests verify both query precedence and body fallback behavior.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is well-scoped, follows existing codebase patterns, includes appropriate tests, and solves a real bug without introducing breaking changes or security concerns
  • No files require special attention

Last reviewed commit: 98bf9a8

Copy link

@nikolasdehor nikolasdehor left a comment

Choose a reason for hiding this comment

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

The code change is correct — query-first precedence maintains backward compat, trim() prevents whitespace-only strings. Missing: tests and a proper PR description for review traceability.

…calls

Gateway browser.request only read profile from query.profile before invoking
browser.proxy on nodes. Calls that passed profile in POST body silently fell
back to the default profile, which could switch users into chrome extension
mode even when they explicitly requested openclaw profile.

Use query profile first, then fall back to body.profile when present.

Closes openclaw#28687
@openclaw-barnacle openclaw-barnacle bot added docs Improvements or additions to documentation channel: bluebubbles Channel integration: bluebubbles channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser app: android App: android app: ios App: ios app: macos App: macos app: web-ui App: web-ui extensions: copilot-proxy Extension: copilot-proxy labels Mar 2, 2026
@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch.

5 similar comments
@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link

Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch.

@steipete steipete reopened this Mar 2, 2026
@openclaw-barnacle openclaw-barnacle bot removed docs Improvements or additions to documentation channel: bluebubbles Channel integration: bluebubbles channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser labels Mar 2, 2026
@steipete
Copy link
Contributor

steipete commented Mar 2, 2026

Landed via temp rebase onto main.

  • Gate: pnpm check && pnpm build && pnpm test
  • Land commit: 98bf9a8
  • Merge commit: 0eebae4

Thanks @Sid-Qin!

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

Labels

gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Browser profile selection bug: chrome profile overrides openclaw even when explicitly specified

3 participants