fix(slack): use z.coerce.string() for timestamp fields to handle LLM numeric inputs #116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
LLMs sometimes pass Slack timestamps as numbers instead of strings (e.g.,
1234567890.123456instead of"1234567890.123456"). The Slack API requires these to be strings, and without coercion, Zod validation would reject numeric timestamps causingslack_sendMessageand related tools to fail with type validation errors.Solution
This change uses
z.coerce.string()instead ofz.string()for all timestamp fields (ts,thread_ts) to automatically convert numbers to strings, making the tools more robust to LLM output variations.Affected tools
sendMessage(ts field)reactToMessage(ts field)readMessage(ts field)readThreadReplies(ts field)reportStatus(thread_ts field)Related
This is a known issue with Slack's API - see:
thread_tsmust be a string not a float slackapi/node-slack-sdk#780