Repository navigation
Conversation
Greptile SummaryAdds defensive sanitization to prevent Changes:
Review findings:
Confidence Score: 4/5
Last reviewed commit: b5a0312 |
| @@ -649,6 +649,8 @@ async function processMessageWithPipeline(params: { | |||
|
|
|||
| const groupSystemPrompt = groupConfigResolved.entry?.systemPrompt?.trim() || undefined; | |||
|
|
|||
| const validThreadId = message.thread?.name?.includes("/messages/") ? undefined : message.thread?.name; | |||
There was a problem hiding this comment.
validThreadId is defined but never used; lines 674-675 duplicate this check inline
| const validThreadId = message.thread?.name?.includes("/messages/") ? undefined : message.thread?.name; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/googlechat/src/monitor.ts
Line: 652
Comment:
`validThreadId` is defined but never used; lines 674-675 duplicate this check inline
```suggestion
```
How can I resolve this? If you propose a fix, please make it concise.|
This pull request has been automatically marked as stale due to inactivity. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18fc247566
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| @@ -230,6 +230,12 @@ async function processMessageWithPipeline(params: { | |||
| body: rawBody, | |||
| }); | |||
|
|
|||
| const groupSystemPrompt = groupConfigResolved.entry?.systemPrompt?.trim() || undefined; | |||
There was a problem hiding this comment.
Remove undefined thread prompt reassignment
processMessageWithPipeline already destructures groupSystemPrompt from access, but this new assignment redeclares groupSystemPrompt and references groupConfigResolved, which is not defined anywhere in the function. That makes extensions/googlechat/src/monitor.ts fail to parse/type-check, so Google Chat monitor code cannot be built or loaded in environments that include this extension.
Useful? React with 👍 / 👎.
|
This pull request has been automatically marked as stale due to inactivity. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d4ebbf3d91
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let thread = (threadId ?? replyToId ?? undefined) as string | undefined; | ||
|
|
||
| if (thread) { | ||
| if (thread.includes("/messages/")) { |
There was a problem hiding this comment.
Coerce thread identifiers before string sanitization
threadId is allowed to be a number in outbound channel contexts (ChannelOutboundContext.threadId), but this new logic casts it to string only at the type level and then immediately calls thread.includes(...). If a numeric threadId reaches Google Chat outbound delivery, sendText/sendMedia will throw a TypeError before sending anything. This turns previously tolerated inputs into hard delivery failures; coerce to a real string (or guard by typeof thread === "string") before using string methods.
Useful? React with 👍 / 👎.
|
This pull request has been automatically marked as stale due to inactivity. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e40e589d0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (thread && /^spaces\/[^/]+\/threads\/[^/]+$/.test(thread)) { | ||
| body.thread = { name: thread }; |
There was a problem hiding this comment.
Reject invalid thread IDs instead of silently dropping them
This new guard turns any non-matching thread into a top-level send instead of an error, which can misroute messages while still returning success. In particular, extensions/googlechat/src/actions.ts passes user-supplied threadId straight through; with this change, malformed/stale values (for example a bare ID or typo) no longer fail fast and instead post to the space root, so automation gets {ok:true} even though the message was delivered to the wrong context. Consider rejecting invalid thread formats (or limiting silent fallback to the specific /messages/ recovery case) so bad thread inputs do not degrade into unintended destinations.
Useful? React with 👍 / 👎.
When replyToId inherits a message resource name, the Google Chat extension passes strings like 'spaces/X/messages/Y' as thread parameters to the Chat API. The API rejects these with INVALID_ARGUMENT since it expects 'spaces/X/threads/Y' format. This commit sanitizes thread IDs in four places: - channel.adapters.ts sendText/sendMedia: drop thread IDs containing '/messages/' and prepend 'spaces/X/threads/' to bare IDs - monitor.ts finalizeInboundContext: filter out message.thread.name values containing '/messages/' before setting ReplyToId - monitor.ts deliverGoogleChatReply: sanitize payload.replyToId before passing to sendGoogleChatMessage - api.ts sendGoogleChatMessage: regex guard as defense-in-depth to only set body.thread when the value matches spaces/X/threads/Y format
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
) Reply routing can hand sendGoogleChatMessage a `thread` that is not a valid `spaces/{space}/threads/{thread}` resource name — a bare id, a `spaces/{space}/messages/{message}` name, or a thread from a different (or wrongly-cased) space. The Chat API rejects the whole request with `400 INVALID_ARGUMENT`, so the reply is never delivered even though the agent already produced it (and did any side effects). Guard the send so the `thread` field and the messageReplyOption fallback are applied only when the thread is a well-formed name belonging to the target space; otherwise post to the space as a new thread. Revives the approach of #28153 (auto-closed as stale) and addresses the failure mode behind #64313.
…claw#108324) Reply routing can hand sendGoogleChatMessage a `thread` that is not a valid `spaces/{space}/threads/{thread}` resource name — a bare id, a `spaces/{space}/messages/{message}` name, or a thread from a different (or wrongly-cased) space. The Chat API rejects the whole request with `400 INVALID_ARGUMENT`, so the reply is never delivered even though the agent already produced it (and did any side effects). Guard the send so the `thread` field and the messageReplyOption fallback are applied only when the thread is a well-formed name belonging to the target space; otherwise post to the space as a new thread. Revives the approach of openclaw#28153 (auto-closed as stale) and addresses the failure mode behind openclaw#64313.
When replyToMode is 'off' (or when threadId inherits a message resource name), the Google Chat extension passes strings like
spaces/X/messages/Yas thread parameters to the Chat API. The API rejects these withINVALID_ARGUMENTsince it expectsspaces/X/threads/Yformat.This commit sanitizes thread IDs in three places:
/messages/and prependspaces/X/threads/to bare IDs missing the prefixfinalizeInboundContext: filter outmessage.thread.namevalues containing/messages/before settingReplyToIdpayload.replyToIdbefore passing to sendGoogleChatMessage, applying the same/messages/guard and bare-ID prefix logicSummary
message.thread.namesometimes returns message resource names (spaces/X/messages/Y) instead of thread resource names (spaces/X/threads/Y). When passed asthreadto the Chat API, it returnsINVALID_ARGUMENT.finalizeInboundContext, deliverGoogleChatReply) to discard/messages/-format strings and normalize bare IDs with the correctspaces/X/threads/prefix.replyToModedefault are untouched.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
INVALID_ARGUMENTwill now be delivered successfully.Security Impact (required)
Repro + Verification
Environment
channels.googlechat.replyToMode: "thread"(also reproducible with"off")Steps
message.thread.nameisspaces/AAAA/threads/BBBB(normal) orspaces/AAAA/messages/CCCC(problematic)threadparameterExpected
Actual
message.thread.namecontains/messages/, the Google Chat API returns:INVALID_ARGUMENT: The request contains an invalid thread resource name spaces/AAAA/messages/CCCCEvidence
Gateway log showing the error before the fix:
Error: 3 INVALID_ARGUMENT: The request contains an invalid thread resource name spaces/AAAA/messages/CCCC. at callErrorFromStatus (...) at Object.onReceiveStatus (...)
After applying the patch, all outbound replies in the same space succeed without errors.
Human Verification (required)
spaces/X/threads/ID);message.thread.namewith/messages/format (dropped toundefined); normalspaces/X/threads/Yformat (passed through unchanged);undefined/missing thread IDs (no-op).replyToMode: "sender"or custom thread session mode. Unit tests not added (no existing test harness for these code paths).Compatibility / Migration
YesFailure Recovery (if this breaks)
undefined), replies would be sent as new top-level messages instead of threaded repliesRisks and Mitigations
/messages/could be incorrectly discarded.spaces/{space}/threads/{thread}format per the API spec. A valid thread name should never contain/messages/. The guard is conservative — it only drops, never mutates, the string.