openclaw - 💡(How to fix) Fix 🐛 Feishu channel fails with tenant_access_token error when HTTP proxy is configured [3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#48949Fetched 2026-04-08 00:50:36
View on GitHub
Comments
3
Participants
3
Timeline
3
Reactions
0
Timeline (top)
commented ×3

Feishu (飞书) channel cannot send messages when system HTTP proxy is configured. Error: Cannot destructure property 'tenant_access_token' of '(intermediate value)' as it is undefined.

Root cause: The @larksuiteoapi/node-sdk uses axios which respects system proxy settings (http_proxy/https_proxy). When proxy is enabled (e.g., v2rayN), requests to open.feishu.cn are routed through the proxy and fail with HTTP 400 error: "The plain HTTP request was sent to HTTPS port".

Error Message

2026-03-17T18:42:11.506+08:00 [delivery-recovery] Retry failed for delivery 0ae83c95-443b-40bb-9e61-48519f90e297: Cannot destructure property 'tenant_access_token' of '(intermediate value)' as it is undefined.

[error]: AxiosError: Request failed with status code 400 ... url: 'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal' ... response: { status: 400, statusText: 'Bad Request', data: '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

<html> <head><title>400 The plain HTTP request was sent to HTTPS port</title></head> <body> <h1>400 Bad Request</h1> <p>The plain HTTP request was sent to HTTPS port.<hr/>Powered by Tengine</body> </html>' }

Root Cause

Root cause: The @larksuiteoapi/node-sdk uses axios which respects system proxy settings (http_proxy/https_proxy). When proxy is enabled (e.g., v2rayN), requests to open.feishu.cn are routed through the proxy and fail with HTTP 400 error: "The plain HTTP request was sent to HTTPS port".

Fix Action

Fix / Workaround

Workaround (Temporary)

Option 2: Patch Lark SDK to disable proxy (what I did to fix locally)

  • Severity: High - Feishu channel is completely unusable for users with HTTP proxy
  • Affected users: Anyone using corporate proxy, v2rayN, Shadowsocks, or similar tools
  • Workaround availability: Requires manual configuration (not user-friendly)

Code Example

2026-03-17T18:42:11.506+08:00 [delivery-recovery] Retry failed for delivery 0ae83c95-443b-40bb-9e61-48519f90e297: Cannot destructure property 'tenant_access_token' of '(intermediate value)' as it is undefined.

[error]: AxiosError: Request failed with status code 400
...
url: 'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal'
...
response: {
  status: 400,
  statusText: 'Bad Request',
  data: '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body>
<h1>400 Bad Request</h1>
<p>The plain HTTP request was sent to HTTPS port.<hr/>Powered by Tengine</body>
</html>'
}

---

export http_proxy="http://127.0.0.1:10808"
   export https_proxy="http://127.0.0.1:10808"

---

{
     "channels": {
       "feishu": {
         "enabled": true,
         "defaultAccount": "main",
         "accounts": {
           "main": {
             "appId": "cli_xxx",
             "appSecret": "xxx"
           }
         }
       }
     }
   }

---

openclaw message send --channel feishu --target oc_xxx --message "test"

---

export NO_PROXY="localhost,127.0.0.1,10.82.1.0/24,open.feishu.cn,*.feishu.cn,feishu.cn"

---

openclaw gateway restart

---

// Before
const defaultHttpInstance = axios__default["default"].create();

// After  
const defaultHttpInstance = axios__default["default"].create({ proxy: false });

---

import axios from "axios";

function configureFeishuAxiosProxy(): void {
  const noProxy = process.env.NO_PROXY || process.env.no_proxy || '';
  const shouldBypass = noProxy.split(',').some(pattern => 
    pattern === 'open.feishu.cn' || 
    pattern === '*.feishu.cn' ||
    pattern === '.feishu.cn' ||
    pattern === 'feishu.cn'
  );
  
  if (shouldBypass) {
    axios.defaults.proxy = false;
  }
}

export function createFeishuClient(creds: FeishuClientCredentials): Lark.Client {
  configureFeishuAxiosProxy();
  // ... rest of client creation
}
RAW_BUFFERClick to expand / collapse

🐛 Bug: Feishu channel fails with tenant_access_token error when HTTP proxy is configured

Summary

Feishu (飞书) channel cannot send messages when system HTTP proxy is configured. Error: Cannot destructure property 'tenant_access_token' of '(intermediate value)' as it is undefined.

Root cause: The @larksuiteoapi/node-sdk uses axios which respects system proxy settings (http_proxy/https_proxy). When proxy is enabled (e.g., v2rayN), requests to open.feishu.cn are routed through the proxy and fail with HTTP 400 error: "The plain HTTP request was sent to HTTPS port".

Environment

Error Details

Gateway Logs

2026-03-17T18:42:11.506+08:00 [delivery-recovery] Retry failed for delivery 0ae83c95-443b-40bb-9e61-48519f90e297: Cannot destructure property 'tenant_access_token' of '(intermediate value)' as it is undefined.

[error]: AxiosError: Request failed with status code 400
...
url: 'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal'
...
response: {
  status: 400,
  statusText: 'Bad Request',
  data: '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body>
<h1>400 Bad Request</h1>
<p>The plain HTTP request was sent to HTTPS port.<hr/>Powered by Tengine</body>
</html>'
}

Key Observation

The error 400 The plain HTTP request was sent to HTTPS port indicates that:

  1. Request is being sent to proxy (127.0.0.1:10808)
  2. Proxy is mishandling the HTTPS CONNECT tunnel
  3. Feishu API server receives plain HTTP instead of HTTPS

Reproduction Steps

  1. Configure system proxy:

    export http_proxy="http://127.0.0.1:10808"
    export https_proxy="http://127.0.0.1:10808"
  2. Configure Feishu channel in ~/.openclaw/openclaw.json:

    {
      "channels": {
        "feishu": {
          "enabled": true,
          "defaultAccount": "main",
          "accounts": {
            "main": {
              "appId": "cli_xxx",
              "appSecret": "xxx"
            }
          }
        }
      }
    }
  3. Start Gateway and attempt to send Feishu message:

    openclaw message send --channel feishu --target oc_xxx --message "test"
  4. Expected: Message sent successfully

  5. Actual: Error Cannot destructure property 'tenant_access_token'

Workaround (Temporary)

Option 1: Add Feishu domains to NO_PROXY

export NO_PROXY="localhost,127.0.0.1,10.82.1.0/24,open.feishu.cn,*.feishu.cn,feishu.cn"

Then restart Gateway:

openclaw gateway restart

Option 2: Patch Lark SDK to disable proxy (what I did to fix locally)

File: /opt/homebrew/lib/node_modules/openclaw/node_modules/@larksuiteoapi/node-sdk/lib/index.js

Change:

// Before
const defaultHttpInstance = axios__default["default"].create();

// After  
const defaultHttpInstance = axios__default["default"].create({ proxy: false });

Proposed Fix

In @openclaw/feishu extension

The Feishu channel plugin should configure the Lark SDK's HTTP instance to bypass proxy for Feishu API domains by default. This is similar to how enterprise SaaS APIs should be accessed directly, not through user's proxy.

Suggested code change in extensions/feishu/src/client.ts:

import axios from "axios";

function configureFeishuAxiosProxy(): void {
  const noProxy = process.env.NO_PROXY || process.env.no_proxy || '';
  const shouldBypass = noProxy.split(',').some(pattern => 
    pattern === 'open.feishu.cn' || 
    pattern === '*.feishu.cn' ||
    pattern === '.feishu.cn' ||
    pattern === 'feishu.cn'
  );
  
  if (shouldBypass) {
    axios.defaults.proxy = false;
  }
}

export function createFeishuClient(creds: FeishuClientCredentials): Lark.Client {
  configureFeishuAxiosProxy();
  // ... rest of client creation
}

Alternative: Better NO_PROXY handling in getWsProxyAgent

The existing getWsProxyAgent() function already checks NO_PROXY for WebSocket client, but the HTTP client (used for API calls) doesn't respect it.

Impact

  • Severity: High - Feishu channel is completely unusable for users with HTTP proxy
  • Affected users: Anyone using corporate proxy, v2rayN, Shadowsocks, or similar tools
  • Workaround availability: Requires manual configuration (not user-friendly)

Additional Context

  • Feishu is an official supported channel in OpenClaw
  • This is a common pattern: enterprise SaaS APIs (Feishu, Lark, etc.) should bypass user proxy by default
  • Similar issues may affect other channels that use axios or similar HTTP libraries

Suggested Priority

🔴 High - Blocks Feishu channel usage for proxy users


Reported by: OpenClaw user (Apple Lobster / 苹果龙虾)
Date: 2026-03-17
Contact: Available via OpenClaw Discord or GitHub

extent analysis

Fix Plan

To resolve the issue with the Feishu channel failing due to tenant_access_token errors when an HTTP proxy is configured, we will implement the following steps:

  1. Modify the @openclaw/feishu extension: Update the extensions/feishu/src/client.ts file to configure the Lark SDK's HTTP instance to bypass the proxy for Feishu API domains by default.
  2. Implement NO_PROXY handling: Enhance the getWsProxyAgent() function to respect the NO_PROXY environment variable for both WebSocket and HTTP clients.

Code Changes

Step 1: Modify client.ts

import axios from "axios";

function configureFeishuAxiosProxy(): void {
  const noProxy = process.env.NO_PROXY || process.env.no_proxy || '';
  const shouldBypass = noProxy.split(',').some(pattern => 
    pattern === 'open.feishu.cn' || 
    pattern === '*.feishu.cn' ||
    pattern === '.feishu.cn' ||
    pattern === 'feishu.cn'
  );
  
  if (shouldBypass) {
    axios.defaults.proxy = false;
  }
}

export function createFeishuClient(creds: FeishuClientCredentials): Lark.Client {
  configureFeishuAxiosProxy();
  // ... rest of client creation
}

Step 2: Update getWsProxyAgent() (if necessary)

Ensure that the getWsProxyAgent() function checks the NO_PROXY environment variable and bypasses the proxy for Feishu API domains.

Verification

To verify that the fix worked:

  1. Configure your system proxy using export http_proxy="http://127.0.0.1:10808" and export https_proxy="http://127.0.0.1:10808".
  2. Restart the Gateway using openclaw gateway restart.
  3. Attempt to send a Feishu message using openclaw message send --channel feishu --target oc_xxx --message "test".
  4. Verify that the message is sent successfully without any tenant_access_token errors.

Extra Tips

  • Ensure that the NO_PROXY environment variable is set correctly to include Feishu API domains.
  • If using a proxy manager like v2rayN, configure it to bypass the proxy for Feishu API domains.
  • Monitor the Gateway logs for any issues related to proxy configuration or Feishu API connectivity.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING