Skip to content

fix: handle string thread_ts from Slack properly#4389

Closed
Chloe-VP wants to merge 1 commit intoopenclaw:mainfrom
Chloe-VP:fix-slack-thread-ts-type
Closed

fix: handle string thread_ts from Slack properly#4389
Chloe-VP wants to merge 1 commit intoopenclaw:mainfrom
Chloe-VP:fix-slack-thread-ts-type

Conversation

@Chloe-VP
Copy link
Copy Markdown
Contributor

@Chloe-VP Chloe-VP commented Jan 30, 2026

Summary

Fixes #4380 - Slack thread_ts messages were being dropped because the queue drain logic used typeof === 'number' to check for thread IDs.

Problem

Slack thread_ts values are strings (e.g., '1737766124.329349'), not numbers. The original code:

if (typeof threadId !== 'number') // This fails for Slack string thread IDs

This caused valid Slack thread messages to be filtered out incorrectly.

Solution

Changed three occurrences in src/auto-reply/reply/queue/drain.ts:

  • Line 43: typeof threadId !== 'number'threadId == null
  • Line 49: typeof threadId === 'number'threadId != null
  • Line 75: typeof originatingThreadId === 'number'originatingThreadId != null

Testing

  • TypeScript compiles without errors
  • Existing queue tests pass (8 tests total)
  • Change allows string thread IDs while still filtering undefined/null values

Notes

This is a straightforward type check fix - no behavioral changes for existing numeric thread IDs.

Greptile Overview

Greptile Summary

This PR updates follow-up queue drain routing so Slack thread_ts values (strings like "1737766124.329349") aren’t dropped by typeof === "number" checks. In src/auto-reply/reply/queue/drain.ts, the cross-channel key derivation and collected-run originatingThreadId selection now treat any non-null thread ID (string or number) as present and stringify it into the routing key, aligning with the originatingThreadId?: string | number type used across the queue pipeline.

Confidence Score: 4/5

  • This PR is likely safe to merge; it’s a small, targeted fix with one edge-case worth confirming.
  • The change correctly aligns drain routing with Slack’s string thread_ts and the existing string | number type. Main risk is minor behavior change if empty-string thread IDs can occur, since the new null-check treats "" as present in one selection path.
  • src/auto-reply/reply/queue/drain.ts (confirm empty-string thread ID cannot occur or should be treated as absent)

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

Context used:

  • Context from dashboard - CLAUDE.md (source)
  • Context from dashboard - AGENTS.md (source)

Issue #4380: The queue drain logic was using typeof === 'number'
to check for thread IDs, which fails for Slack where thread_ts
is a string like '1737766124.329349'.

Changed three occurrences:
- Line 43: typeof threadId !== 'number' → threadId == null
- Line 49: typeof threadId === 'number' → threadId != null
- Line 75: typeof originatingThreadId === 'number' → originatingThreadId != null

This allows Slack string thread IDs to be properly recognized
while still filtering out undefined/null values.
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines 74 to 76
const originatingThreadId = items.find(
(i) => typeof i.originatingThreadId === "number",
(i) => i.originatingThreadId != null,
)?.originatingThreadId;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1] originatingThreadId selection now picks the first non-null value, which includes "" (empty string). That can change routing/collect behavior by treating empty thread IDs as a real thread (vs previously only numeric IDs were considered). If empty-string thread IDs are possible from any provider normalization, this could cause messages to be grouped under a distinct thread key or passed through as originatingThreadId: "".

Consider mirroring the normalization behavior used elsewhere (e.g., treat "" as absent) by checking i.originatingThreadId != null && i.originatingThreadId !== "".

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/auto-reply/reply/queue/drain.ts
Line: 74:76

Comment:
[P1] `originatingThreadId` selection now picks the first *non-null* value, which includes `""` (empty string). That can change routing/collect behavior by treating empty thread IDs as a real thread (vs previously only numeric IDs were considered). If empty-string thread IDs are possible from any provider normalization, this could cause messages to be grouped under a distinct thread key or passed through as `originatingThreadId: ""`.

Consider mirroring the normalization behavior used elsewhere (e.g., treat `""` as absent) by checking `i.originatingThreadId != null && i.originatingThreadId !== ""`.

How can I resolve this? If you propose a fix, please make it concise.

@Lukavyi
Copy link
Copy Markdown
Contributor

Lukavyi commented Feb 7, 2026

Hey! I ran into the same issue and submitted #11194 which builds on this approach but adds empty-string edge case protection (threadId != null && threadId !== "" instead of just threadId == null). This addresses the concern Greptile raised in the review here — if any provider normalizes missing thread IDs to "", the != null check alone would treat it as a real thread. Also added 3 test cases for string thread_ts handling.

@sebslight
Copy link
Copy Markdown
Member

Closing as duplicate of #4749. If this is incorrect, comment and we can reopen.

@sebslight sebslight closed this Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Slack thread_ts lost during collect queue drain — typeof === "number" check drops string thread IDs

3 participants