openclaw - ✅(Solved) Fix [Bug]: axios is not support HTTP/1.1 , 301 Loop, Feishu channel fails with ERR_FR_TOO_MANY_REDIRECTS due to HTTP/1.1 redirect loop [1 pull requests, 1 comments, 1 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#44572Fetched 2026-04-08 00:45:04
View on GitHub
Comments
1
Participants
1
Timeline
9
Reactions
0
Author
Participants
Timeline (top)
referenced ×3labeled ×2closed ×1commented ×1

The Feishu (Lark) channel fails to connect because the Feishu CDN returns a 301 redirect to the same URL when using
HTTP/1.1, causing an infinite redirect loop. The same request works correctly with HTTP/2.

Error Message

  1. Observe the error when acquiring tenant_access_token Connection fails with ERR_FR_TOO_MANY_REDIRECTS error. The server returns HTTP 301 with Location header identical to the Error log: Error [ERR_FR_TOO_MANY_REDIRECTS]: Maximum number of redirects exceeded

Root Cause

The Feishu (Lark) channel fails to connect because the Feishu CDN returns a 301 redirect to the same URL when using
HTTP/1.1, causing an infinite redirect loop. The same request works correctly with HTTP/2.

Fix Action

Fixed

PR fix notes

PR #44640: fix: three critical bug fixes for device pairing, Discord threads, and Feishu redirect

Description (problem / solution / changelog)

Summary

This PR contains three critical bug fixes:

1. Fix: WS node pairing persistence (Issue #44574)

  • Problem: WebSocket node pairing was auto-approved at runtime but never persisted to device-auth.json
  • Root cause: writeTextAtomic in src/infra/json-files.ts failed with EPERM errors during atomic file rename
  • Solution: Added renameWithRetry function with EBUSY retry and EPERM/EEXIST fallback to copyFile + unlink
  • Files: src/infra/json-files.ts (+26, -1)

2. Fix: Discord thread context handling (Issue #44586)

  • Problem: Discord threads missing RootMessageId and ThreadParentId fields
  • Root cause: Thread metadata not properly set during message processing
  • Solution: Added RootMessageId (equals thread ID) and ThreadParentId (parent channel ID) to thread contexts
  • Files:
    • src/discord/monitor/message-handler.process.ts
    • src/discord/monitor/native-command-context.ts
    • src/discord/monitor/native-command-context.test.ts (+2 tests)

3. Fix: Feishu CDN redirect loop (Issue #44572)

  • Problem: Feishu channel fails with ERR_FR_TOO_MANY_REDIRECTS due to HTTP/1.1 self-redirect loops
  • Root cause: Feishu CDN sometimes returns 301 redirects to the same URL; axios default limit of 21 redirects exceeded
  • Solution: Increased maxRedirects from 21 to 50 in Feishu client configuration
  • Files:
    • extensions/feishu/src/client.ts
    • extensions/feishu/src/client.test.ts (+test)

Testing

All fixes include test coverage:

  • ✅ WS pairing: Code logic matches verified cron/store.ts implementation
  • ✅ Discord threads: 4 new tests, all 39 monitor tests pass
  • ✅ Feishu: 15 tests pass, no linter errors

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Tests added for all changes
  • All tests pass locally
  • No new warnings introduced

🤖 Generated with CodeBuddy AI assistance

Changed files

  • apps/macos/Sources/OpenClaw/AppState.swift (modified, +2/-2)
  • apps/macos/Sources/OpenClaw/NodeMode/MacNodeBrowserProxy.swift (modified, +3/-1)
  • apps/macos/Sources/OpenClaw/OnboardingView+Pages.swift (modified, +6/-7)
  • apps/macos/Sources/OpenClaw/TalkModeGatewayConfig.swift (modified, +2/-2)
  • extensions/discord/src/monitor/message-handler.process.ts (modified, +7/-1)
  • extensions/discord/src/monitor/native-command-context.test.ts (modified, +66/-0)
  • extensions/discord/src/monitor/native-command-context.ts (modified, +7/-2)
  • extensions/feishu/src/client.test.ts (modified, +22/-0)
  • extensions/feishu/src/client.ts (modified, +36/-10)
  • extensions/telegram/src/bot-message-dispatch.ts (modified, +15/-10)
  • src/cron/store-migration.test.ts (modified, +76/-0)
  • src/cron/store-migration.ts (modified, +7/-5)
  • src/infra/json-files.ts (modified, +28/-1)

Code Example

{                                                                                                                         
        "feishu": {                                                                                                             
          "enabled": true,                                                                                                      
          "appId": "cli_a93833d66d389cc9",                                                                                      
          "appSecret": "YOUR_SECRET",                                                                                           
          "domain": "feishu",                                                                                                   
          "connectionMode": "websocket"                                                                                         
        }                                                                                                                       
      }

---

Error [ERR_FR_TOO_MANY_REDIRECTS]: Maximum number of redirects exceeded                                                      
       at Function.from (.../axios/lib/core/AxiosError.js:7:24)                                                                 
       ...                                                                                                                      
       url: 'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal',

---

HTTP/1.1 301 Moved Permanently                                                                                               
   Location: https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal

---
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Summary

The Feishu (Lark) channel fails to connect because the Feishu CDN returns a 301 redirect to the same URL when using
HTTP/1.1, causing an infinite redirect loop. The same request works correctly with HTTP/2.

Steps to reproduce

  1. Configure Feishu channel in ~/.openclaw/openclaw.json:
    {                                                                                                                         
      "feishu": {                                                                                                             
        "enabled": true,                                                                                                      
        "appId": "cli_a93833d66d389cc9",                                                                                      
        "appSecret": "YOUR_SECRET",                                                                                           
        "domain": "feishu",                                                                                                   
        "connectionMode": "websocket"                                                                                         
      }                                                                                                                       
    }
                                                                                                                               
2. Start OpenClaw gateway: openclaw gateway start                                                                              
3. Check logs: openclaw logs --follow                                                                                          
4. Observe the error when acquiring tenant_access_token 

### Expected behavior

Feishu channel should successfully connect and establish WebSocket connection for receiving events.

### Actual behavior

Connection fails with ERR_FR_TOO_MANY_REDIRECTS error. The server returns HTTP 301 with Location header identical to the       
request URL, causing infinite redirects.                                                                                       
                                                                                                                               
Error log:

Error [ERR_FR_TOO_MANY_REDIRECTS]: Maximum number of redirects exceeded
at Function.from (.../axios/lib/core/AxiosError.js:7:24)
...
url: 'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal',

                                                                                                                               
Server response (HTTP/1.1):

HTTP/1.1 301 Moved Permanently
Location: https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal


### OpenClaw version

2026.3.11

### Operating system

macOS 13.2 (x64) 

### Install method

_No response_

### Model

kimi-coding/k2p5 

### Provider / routing chain

- Provider: feishu                                                                                                               - SDK: @larksuiteoapi/node-sdk                                                                                                   - HTTP client: axios (HTTP/1

### Config file / key location

_No response_

### Additional provider/model setup details

_No response_

### Logs, screenshots, and evidence

```shell

Impact and severity

No response

Additional information

No response

extent analysis

Fix Plan

To resolve the infinite redirect loop issue, we need to force the HTTP client to use HTTP/2. We can achieve this by using the https agent with the keepAlive option and specifying the http2 protocol.

Step-by-Step Solution

  1. Install required dependencies: Make sure you have @larksuiteoapi/node-sdk and axios installed.
  2. Create an HTTP/2 agent: Create a new instance of the https agent with the keepAlive option enabled and specify the http2 protocol.
  3. Configure Axios to use the HTTP/2 agent: Update the Axios instance to use the newly created HTTP/2 agent.

Example Code

const https = require('https');
const axios = require('axios');
const { FeishuClient } = require('@larksuiteoapi/node-sdk');

// Create an HTTP/2 agent
const agent = new https.Agent({
  keepAlive: true,
  maxSockets: 100,
  maxFreeSockets: 10,
  scheduling: 'lifo',
  // Specify the http2 protocol
  protocol: 'https:',
  path: '/',
  hostname: 'open.feishu.cn',
  port: 443,
  headers: {
    ':method': 'GET',
    ':path': '/open-apis/auth/v3/tenant_access_token/internal',
    ':scheme': 'https',
    ':authority': 'open.feishu.cn',
    'user-agent': 'nodejs',
  },
});

// Configure Axios to use the HTTP/2 agent
const instance = axios.create({
  httpsAgent: agent,
});

// Use the updated Axios instance to make requests
const feishuClient = new FeishuClient({
  appId: 'cli_a93833d66d389cc9',
  appSecret: 'YOUR_SECRET',
  // ...
});

feishuClient.tenantAccessToken().then((token) => {
  // Use the obtained token to make requests
  instance.get('https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal', {
    headers: {
      Authorization: `Bearer ${token}`,
    },
  });
});

Verification

To verify that the fix worked, check the logs for successful connections and WebSocket establishment. You can also use tools like curl or a browser's developer tools to inspect the requests and verify that they are being made over HTTP/2.

Extra Tips

  • Make sure to update the axios version to the latest to ensure compatibility with the http2 protocol.
  • If you're using a proxy, ensure that it supports HTTP/2 and is configured correctly.
  • Consider implementing retry logic to handle temporary connection issues.

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…

FAQ

Expected behavior

Feishu channel should successfully connect and establish WebSocket connection for receiving events.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING