openclaw - ✅(Solved) Fix GChat: infinite thread reply retry loop on INVALID_ARGUMENT thread resource name [1 pull requests, 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#64313Fetched 2026-04-11 06:15:23
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1referenced ×1

When a user replies to a Clanker message in a Google Chat space, the gateway enters an infinite retry loop with Google Chat API 400: The request contains an invalid thread resource name (INVALID_ARGUMENT).

Error Message

In deliverGoogleChatReply() (channel-X_UZamo0.js), the sendGoogleChatMessage call unconditionally passes thread: payload.replyToId. There is no error handling for INVALID_ARGUMENT on the thread parameter — the catch block logs the error and the caller retries, creating the loop.

Root Cause

Root cause (traced in source)

In deliverGoogleChatReply() (channel-X_UZamo0.js), the sendGoogleChatMessage call unconditionally passes thread: payload.replyToId. There is no error handling for INVALID_ARGUMENT on the thread parameter — the catch block logs the error and the caller retries, creating the loop.

Fix Action

Workaround

Users must always send new top-level messages in GChat and never reply to Clanker messages. Gateway restart clears the in-memory loop temporarily, but it resumes on the next incoming message in the same thread.

PR fix notes

PR #64325: fix(googlechat): fallback to top-level message on INVALID_ARGUMENT thread error

Description (problem / solution / changelog)

Summary

Fixes #64313 — GChat infinite thread reply retry loop on INVALID_ARGUMENT thread resource name.

Problem

When a user replies to a bot message in Google Chat, the gateway attempts to reply in the same thread using payload.replyToId. If the thread resource name is invalid or malformed, the Google Chat API returns 400 INVALID_ARGUMENT. The existing error handler only logs the error, and the caller retries indefinitely — flooding logs and blocking the conversation.

Fix

In sendGoogleChatMessage(), catch INVALID_ARGUMENT errors when a thread parameter is present, then retry the same message without the thread — gracefully degrading to a new top-level message in the space.

This is consistent with Google's own REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD semantics, but handles the case where the thread name itself is rejected before the API can apply that fallback.

Changes

  • extensions/googlechat/src/api.ts: Wrap the fetchJson call in a try/catch. On INVALID_ARGUMENT with a thread param, strip body.thread and retry to the base messages endpoint.

Testing

  • Manual: Confirmed that non-thread errors are still re-thrown (not swallowed).
  • The fix is narrowly scoped to INVALID_ARGUMENT + thread presence, so existing thread reply behavior is unchanged for valid threads.

Changed files

  • extensions/googlechat/src/api.ts (modified, +22/-5)

Code Example

await sendGoogleChatMessage({
  account,
  space: spaceId,
  text: chunk,
  thread: payload.replyToId  // no fallback if thread is invalid
});
RAW_BUFFERClick to expand / collapse

Version: 2026.4.9 Platform: macOS 26.4 (arm64), Node 25.8.1

Summary

When a user replies to a Clanker message in a Google Chat space, the gateway enters an infinite retry loop with Google Chat API 400: The request contains an invalid thread resource name (INVALID_ARGUMENT).

Steps to reproduce

  1. Clanker sends a message in a Google Chat space
  2. User replies to that message (creating/using a GChat thread)
  3. Clanker attempts to reply back into that thread
  4. Google Chat API returns 400 INVALID_ARGUMENT: The request contains an invalid thread resource name
  5. Gateway retries indefinitely — multiple times per second — flooding the log

Root cause (traced in source)

In deliverGoogleChatReply() (channel-X_UZamo0.js), the sendGoogleChatMessage call unconditionally passes thread: payload.replyToId. There is no error handling for INVALID_ARGUMENT on the thread parameter — the catch block logs the error and the caller retries, creating the loop.

await sendGoogleChatMessage({
  account,
  space: spaceId,
  text: chunk,
  thread: payload.replyToId  // no fallback if thread is invalid
});

Expected behaviour

On INVALID_ARGUMENT for the thread parameter, retry the send without the thread param (post as a new top-level message in the space).

Workaround

Users must always send new top-level messages in GChat and never reply to Clanker messages. Gateway restart clears the in-memory loop temporarily, but it resumes on the next incoming message in the same thread.

Config knob requested

A channels.googlechat.threadReply: false option to disable thread replies entirely would also resolve this class of problem.

extent analysis

TL;DR

Modify the deliverGoogleChatReply() function to handle INVALID_ARGUMENT errors for the thread parameter by retrying the send without the thread parameter.

Guidance

  • Identify the deliverGoogleChatReply() function in channel-X_UZamo0.js and modify the sendGoogleChatMessage call to include error handling for INVALID_ARGUMENT errors.
  • Implement a retry mechanism that removes the thread parameter if an INVALID_ARGUMENT error occurs, allowing the message to be posted as a new top-level message in the space.
  • Consider adding a configuration option, such as channels.googlechat.threadReply: false, to disable thread replies entirely and prevent this issue.
  • Verify that the modified function correctly handles INVALID_ARGUMENT errors and retries the send without the thread parameter.

Example

try {
  await sendGoogleChatMessage({
    account,
    space: spaceId,
    text: chunk,
    thread: payload.replyToId
  });
} catch (error) {
  if (error.code === 400 && error.message.includes('INVALID_ARGUMENT')) {
    // Retry without thread parameter
    await sendGoogleChatMessage({
      account,
      space: spaceId,
      text: chunk
    });
  } else {
    // Handle other errors
  }
}

Notes

This solution assumes that the sendGoogleChatMessage function is correctly implemented and only the error handling for INVALID_ARGUMENT errors needs to be added. Additionally, the channels.googlechat.threadReply: false configuration option may not be implemented, but it is suggested as a potential solution to prevent this issue.

Recommendation

Apply workaround by modifying the deliverGoogleChatReply() function to handle INVALID_ARGUMENT errors and retry the send without the thread parameter, as this will prevent the infinite retry loop and allow messages to be posted correctly.

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