Skip to content

fix: send thread_ts once in chat.postMessage requests - #1684

Open
Adam-Schildkraut wants to merge 5 commits into
slackapi:mainfrom
Adam-Schildkraut:fix/chat-post-message-thread-ts
Open

Adam-Schildkraut wants to merge 5 commits into
slackapi:mainfrom
Adam-Schildkraut:fix/chat-post-message-thread-ts

Conversation

@Adam-Schildkraut

@Adam-Schildkraut Adam-Schildkraut commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

When chat.postMessage is given a thread timestamp, the SDK adds thread_ts to the form body twice. Both entries contain the same value, but clients inspecting the request can fail when they expect one value per field.

The field is already added earlier in the same method. This removes the second insertion. The test checks that each expected field in a populated message form appears exactly once, regardless of order. It fails before the fix and passes afterwards.

Validation: RequestFormBuilderTest and the local ChatTest suite on Java 17.

Category (place an x in each of the [ ])

  • bolt (Bolt for Java)
  • bolt-{sub modules} (Bolt for Java - optional modules)
  • slack-api-client (Slack API Clients)
  • slack-api-model (Slack API Data Models)
  • slack-api-*-kotlin-extension (Kotlin Extensions for Slack API Clients)
  • slack-app-backend (The primitive layer of Bolt for Java)

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you agree to those rules.

@Adam-Schildkraut
Adam-Schildkraut requested a review from a team as a code owner November 12, 2026 00:49
@Adam-Schildkraut

Copy link
Copy Markdown
Contributor Author

hey again @mwbrooks! this one’s much simpler than my last PR 😄 caught thread_ts being added twice in RequestFormBuilder, so I removed the duplicate and added a test checking that each expected field in the message form appears exactly once from now on!

@WilliamBergamin WilliamBergamin added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented project:slack-api-client project:slack-api-client labels Nov 12, 2026

@WilliamBergamin WilliamBergamin left a comment

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.

🧪 Thanks @Adam-Schildkraut! Pinning every chat.postMessage field to exactly one occurrence is a nice way to guard this, and it fails on the old double insert.
Left a couple of comments 💯

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.75%. Comparing base (c847d97) to head (8cba831).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1684      +/-   ##
============================================
- Coverage     73.75%   73.75%   -0.01%     
- Complexity     4679     4682       +3     
============================================
  Files           487      487              
  Lines         14669    14668       -1     
  Branches       1528     1528              
============================================
- Hits          10819    10818       -1     
- Misses         2939     2942       +3     
+ Partials        911      908       -3     
Flag Coverage Δ
jdk-14 73.75% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@zimeg zimeg changed the title Fix duplicate thread_ts in chat.postMessage requests fix: send thread_ts once in chat.postMessage requests Nov 12, 2026
@zimeg

zimeg commented Nov 12, 2026

Copy link
Copy Markdown
Member

🔭 question: Thanks for finding this duplicate! Could this be solved more generically in RequestFormBuilder rather than in chat.postMessage alone? Right now setIfNotNull adds a field every time it's called, so another toForm method could repeat a field the same way. A guard where the form gets built, or a test that runs every toForm with all fields set and checks that each field name appears once, might keep this from coming back. I'm curious what you think!

@Adam-Schildkraut

Copy link
Copy Markdown
Contributor Author

hey @WilliamBergamin! thanks, good catch 😄 i’ve added that assert, so the test now checks that thread_ts appears once and contains the correct timestamp!

@Adam-Schildkraut

Copy link
Copy Markdown
Contributor Author

heya @zimeg!! i took your broader-test suggestion and pushed it! so the existing RequestFormBuilderTest now checks every toForm method for duplicate field names. it also exercises JSON-string and object inputs separately, since setting everything at once skips some alternative paths

@WilliamBergamin

Copy link
Copy Markdown
Contributor

@Adam-Schildkraut could you resolve the merge conflict once addressed I can give this another review 🙏

@Adam-Schildkraut

Copy link
Copy Markdown
Contributor Author

@WilliamBergamin fixed!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented cla:signed project:slack-api-client project:slack-api-client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants