Skip to content

Fix Slack connector float timestamp causing messages to be deleted on scheduled syncs (#3032)#3997

Merged
seanstory merged 4 commits into
elastic:mainfrom
sukhadagholba:fix/slack-timestamp-decimal-truncation
May 19, 2026
Merged

Fix Slack connector float timestamp causing messages to be deleted on scheduled syncs (#3032)#3997
seanstory merged 4 commits into
elastic:mainfrom
sukhadagholba:fix/slack-timestamp-decimal-truncation

Conversation

@sukhadagholba
Copy link
Copy Markdown
Contributor

@sukhadagholba sukhadagholba commented Apr 23, 2026

Closes #3032

Problem

time.time() in Python returns a float with decimal places (e.g. 1745123456.561659).
These float timestamps are passed directly to the Slack conversations.history API
as oldest and latest parameters.

The Slack API inconsistently rejects decimal timestamps — returning no messages when
decimals are present, despite the docs showing decimal format in examples. This causes
the connector to successfully sync all messages on the first manual full sync, but all
subsequent scheduled syncs return no messages and only sync users, permanently deleting
all previously indexed messages until another manual full sync is triggered.

  • Run 1 (manual full sync) → ~4,750 documents (messages + users) ✅
  • Run 2 (scheduled sync) → 613 documents (users only, ~4,137 messages deleted) ❌
  • All subsequent scheduled syncs → 613 documents only ❌

This issue was first reported in December 2024. As of April 2026, 16 months later,
Slack has not resolved the inconsistent API behavior, making this connector-side
fix necessary to unblock users. While the root cause may lie in inconsistent Slack
API behavior, this defensive fix on the connector side ensures reliable syncing
regardless of whether Slack resolves the inconsistency on their end.

Fix

Truncate float timestamps to int before passing to the Slack API:

current_unix_timestamp = int(time.time())
past_unix_timestamp = int(current_unix_timestamp - self.n_days_to_fetch * 24 * 3600)

Testing

Applied this fix to the v9.1.4 tag and tested against Elasticsearch 9.1.4:

  • Run 1 (manual full sync) → ~4,750 documents (messages + users) ✅
  • Run 2 (scheduled sync) → ~4,750 documents retained ✅
  • Run 3 (scheduled sync) → ~4,750 documents retained ✅

Messages are no longer deleted on scheduled syncs confirming the fix works as expected.

Checklists

Pre-Review Checklist

  • this PR does NOT contain credentials of any kind
  • this PR has a meaningful title
  • this PR links to all relevant github issues that it fixes
  • this PR has a thorough description
  • All 9 Slack unit tests pass including test_channels_and_messages_uses_integer_timestamps which directly validates the fix
  • Tested the fix locally on connector v9.1.4 tag against Elasticsearch 9.1.4 — messages retained across multiple scheduled syncs

@sukhadagholba sukhadagholba requested a review from a team as a code owner April 23, 2026 23:16
@cla-checker-service
Copy link
Copy Markdown

cla-checker-service Bot commented Apr 23, 2026

💚 CLA has been signed

@seanstory
Copy link
Copy Markdown
Member

buildkite test this

@seanstory
Copy link
Copy Markdown
Member

Thanks for the contribution, @sukhadagholba! In order for us to accept it, you'll need to sign the Contributor License Agreement with the same email address you use for your Github user.

@seanstory
Copy link
Copy Markdown
Member

buildkite test this

1 similar comment
@seanstory
Copy link
Copy Markdown
Member

buildkite test this

@sukhadagholba
Copy link
Copy Markdown
Contributor Author

Thanks for the contribution, @sukhadagholba! In order for us to accept it, you'll need to sign the Contributor License Agreement with the same email address you use for your Github user.

@seanstory Thank you, just signed the Contributor License Agreement

@seanstory
Copy link
Copy Markdown
Member

buildkite test this

@sukhadagholba
Copy link
Copy Markdown
Contributor Author

@seanstory - I see that the CLA check appears to be failing, do I need to re-sign the Contributor License Agreement or does the check take a bit to pass?

@seanstory
Copy link
Copy Markdown
Member

I would have expected it to re-trigger. Looking closer, this has to do with commits, and it looks like your commits are made by sukhada not by sukhadagholba. Double check that your commits are associated with the email address that you signed the CLA with.
Like, in my ~/.gitconfig I have:

[user]
    name = Sean Story
    email = sean.story@elastic.co

You may need to fix some local git config and rebase to re-write the history to be associated with your github user.

@sukhadagholba sukhadagholba force-pushed the fix/slack-timestamp-decimal-truncation branch 2 times, most recently from 0c22469 to 2d25fb9 Compare May 18, 2026 19:11
@sukhadagholba
Copy link
Copy Markdown
Contributor Author

Thank you @seanstory ! Fixed the issue, CLA checks seem to pass now.

@seanstory
Copy link
Copy Markdown
Member

buildkite test this

@seanstory seanstory enabled auto-merge (squash) May 18, 2026 19:18
time.time() returns a float with decimal places which causes the Slack
conversations.history API to return no messages. Truncating to int fixes
the issue. Fixes elastic#3032
auto-merge was automatically disabled May 18, 2026 19:56

Head branch was pushed to by a user without write access

@sukhadagholba sukhadagholba force-pushed the fix/slack-timestamp-decimal-truncation branch from 2d25fb9 to 8cb9280 Compare May 18, 2026 19:56
@sukhadagholba
Copy link
Copy Markdown
Contributor Author

@seanstory Synced branch with latest main to resolve the out-of-date warning. Could you please re-enable auto-merge? Thanks!

@seanstory
Copy link
Copy Markdown
Member

buildkite test this

@seanstory seanstory enabled auto-merge (squash) May 18, 2026 20:11
@seanstory
Copy link
Copy Markdown
Member

@sukhadagholba looks like the linter is failing. Should be as easy as running make autoformat 🤞

auto-merge was automatically disabled May 18, 2026 23:40

Head branch was pushed to by a user without write access

@sukhadagholba
Copy link
Copy Markdown
Contributor Author

@sukhadagholba looks like the linter is failing. Should be as easy as running make autoformat 🤞

@seanstory Done! Thank you!

Copy link
Copy Markdown
Contributor

@Jan-Kazlouski-elastic Jan-Kazlouski-elastic left a comment

Choose a reason for hiding this comment

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

LGTM

@seanstory
Copy link
Copy Markdown
Member

buildkite test this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@sukhadagholba I expect that you generated this after having installed test dependencies. I'm pretty sure CI will undo all the additions, but just gonna mark this as "request changes" to make sure we don't merge +15k additions here.

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.

Good catch @seanstory !
Also, is it normal for PR to have an issue number as part of the PR name?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is it normal for PR to have an issue number as part of the PR name?

It's not abnormal. But we don't have a strong policy about how you associate a PR with an issue, as long as you do.

I'm pretty sure CI will undo all the additions

Doesn't look like it did, and I expect that's because our bot can't push commits to your fork. So, @sukhadagholba can I ask you to:

  1. delete this NOTICE.txt
  2. make clean notice
  3. commit the NOTICE changes
  4. push

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@seanstory Done! Deleted NOTICE.txt, ran make clean notice, committed and pushed the changes.

@Jan-Kazlouski-elastic Jan-Kazlouski-elastic self-requested a review May 19, 2026 14:56
@seanstory
Copy link
Copy Markdown
Member

buildkite test this

@seanstory seanstory enabled auto-merge (squash) May 19, 2026 20:33
@seanstory seanstory merged commit fac84d2 into elastic:main May 19, 2026
2 checks passed
@github-actions
Copy link
Copy Markdown

💔 Failed to create backport PR(s)

Status Branch Result
9.5 The branch "9.5" is invalid or doesn't exist

To backport manually run:
backport --pr 3997 --autoMerge --autoMergeMethod squash

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to fetch slack messages due to incorrect timestamp format

3 participants