Skip to content

v0.5.107: new reddit, slack tools#3437

Merged
waleedlatif1 merged 2 commits intomainfrom
staging
Mar 6, 2026
Merged

v0.5.107: new reddit, slack tools#3437
waleedlatif1 merged 2 commits intomainfrom
staging

Conversation

@waleedlatif1
Copy link
Collaborator

…nst API docs (#3434)

* feat(reddit): add 5 new tools, fix bugs, and audit all endpoints against API docs

* fix(reddit): add optional chaining, pagination wiring, and trim safety

- Add optional chaining on children?.[0] in get_posts, get_controversial,
  search, and get_comments to prevent TypeError on unexpected API responses
- Wire after/before pagination params to get_messages block operation
- Use ?? instead of || for get_comments limit to handle 0 correctly
- Add .trim() on postId in get_comments URL path

* chore(reddit): remove unused output property constants from types.ts

* fix(reddit): add HTTP error handling to GET tools

Add !response.ok guards to get_me, get_user, get_subreddit_info,
and get_messages to return success: false on non-2xx responses
instead of silently returning empty data with success: true.

* fix(reddit): add input validation and HTTP error guards

- Add validateEnum/validatePathSegment to prevent URL path traversal
- Add !response.ok guards to send_message and reply tools
- Centralize subreddit validation in normalizeSubreddit
…tools (#3436)

* feat(slack): add views.open, views.update, views.push, views.publish tools

* feat(slack): wire view tools into slack block definition
@vercel
Copy link

vercel bot commented Mar 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Mar 6, 2026 6:21am

Request Review

@waleedlatif1 waleedlatif1 marked this pull request as ready for review March 6, 2026 06:45
@cursor
Copy link

cursor bot commented Mar 6, 2026

PR Summary

Medium Risk
Adds multiple new external-API tool endpoints and expands existing Reddit response/param shapes (pagination cursors, thing fullnames, stricter input validation), which may subtly affect existing workflows and downstream consumers. Slack changes are mostly additive but introduce new JSON view payload handling that could fail at runtime if payloads are malformed or scopes are missing.

Overview
Expands Reddit tool coverage and hardens requests. Adds new Reddit tools for get_me, get_user, send_message, get_messages, and get_subreddit_info, plus updates block/docs to expose them. Existing Reddit endpoints gain pagination cursors (after/before), thing fullnames (name), new query options (e.g., controversial sort, geo g, search type/sr_detail, comment comment focus, submit flair/collection fields), improved error handling, and stricter path/enum validation to prevent invalid inputs.

Adds Slack view/modals APIs. Introduces slack_open_view, slack_update_view, slack_push_view, and slack_publish_view (with shared view output typing), wires them into the Slack block UI (new operations + JSON viewPayload input), and updates Slack docs/descriptions accordingly.

Written by Cursor Bugbot for commit 127968d. Configure here.

@waleedlatif1 waleedlatif1 merged commit 6586c5c into main Mar 6, 2026
27 checks passed
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 6, 2026

Greptile Summary

This PR adds 5 new Reddit tools (get_me, get_user, send_message, get_messages, get_subreddit_info) and 4 new Slack view tools (open_view, update_view, push_view, publish_view), along with a comprehensive audit of existing Reddit endpoints to align them with the official API docs (pagination, flair, geo-filter support, wandConfig AI prompts, and UI polish).

Key changes:

  • Reddit block: 5 new operations, improved field organization with section comments, new wandConfig prompts for search/post/reply/message, refactored tool dispatch to a clean lookup map
  • Slack block: 4 new view/modal operations added to the operation selector and correctly excluded from channel/DM-specific field conditions
  • New shared VIEW_OUTPUT_PROPERTIES in slack/types.ts reused across all four view tools
  • All new tools follow consistent patterns: OAuth injection, visibility: 'hidden' for accessToken, input sanitization via validatePathSegment/validateEnum, and typed response interfaces
  • get_posts.ts is missing a response.ok check — API errors are silently swallowed and return success: true with an empty posts array (all other Reddit tools handle this correctly)
  • update_view.ts has no runtime guard ensuring at least one of viewId/externalId is provided before sending the request to Slack
  • Minor docs inaccuracy: slack_publish_view output table describes the view type as "modal" when it should be "home"

Confidence Score: 4/5

  • Safe to merge with minor fixes — two logic gaps should be addressed before relying on the tools in production workflows.
  • The majority of new tools are well-implemented, follow established patterns, and include proper input validation and error handling. Two issues lower the score: (1) get_posts.ts silently swallows API errors (inconsistent with every other Reddit tool), and (2) update_view.ts will send a request to Slack without the required view_id/external_id if both are left blank.
  • apps/sim/tools/reddit/get_posts.ts and apps/sim/tools/slack/update_view.ts need the most attention.

Important Files Changed

Filename Overview
apps/sim/tools/reddit/get_posts.ts New get_posts tool with sorting, pagination, and geo-filter support. Missing error handling for non-OK API responses — can silently return empty results on errors.
apps/sim/tools/slack/update_view.ts New views.update tool. Both viewId and externalId are optional with no runtime guard, allowing requests to be sent without either required identifier.
apps/sim/tools/slack/open_view.ts New views.open tool. Well-structured with comprehensive error handling for all known Slack API errors and proper trigger_id handling.
apps/sim/tools/slack/push_view.ts New views.push tool. Mirrors open_view with correct push-specific error handling (push_limit_reached).
apps/sim/tools/slack/publish_view.ts New views.publish tool for Home tab. Clean implementation with appropriate error handling.
apps/sim/tools/reddit/get_me.ts New tool to fetch authenticated Reddit user info. Straightforward implementation with proper error fallback.
apps/sim/tools/reddit/get_user.ts New tool for public Reddit user profile lookup. Includes proper path traversal protection via validatePathSegment.
apps/sim/tools/reddit/send_message.ts New tool to send Reddit private messages. Handles API-level errors in json.errors array and HTTP errors correctly.
apps/sim/tools/reddit/get_messages.ts New tool to retrieve Reddit inbox messages. Includes enum validation for the folder parameter and full pagination support.
apps/sim/tools/reddit/get_subreddit_info.ts New tool to fetch subreddit metadata. Uses normalizeSubreddit for sanitization and proper error fallback.
apps/sim/blocks/blocks/reddit.ts Reddit block updated with 5 new operations, advanced field groups, wandConfig AI prompts, and a clean tool dispatch map. Well organized.
apps/sim/blocks/blocks/slack.ts Slack block updated to add 4 new view operations. Channel/DM field conditions correctly exclude the new view operations.
apps/sim/tools/reddit/types.ts New interfaces and shared output property definitions for all new Reddit tools, well-structured with full type coverage.
apps/sim/tools/slack/types.ts New SlackView interface and VIEW_OUTPUT_PROPERTIES added for all four view tools. Consistent with existing type patterns.

Sequence Diagram

sequenceDiagram
    participant User
    participant RedditBlock
    participant SlackBlock
    participant RedditAPI as Reddit OAuth API
    participant SlackAPI as Slack API

    Note over RedditBlock: New Reddit tools
    User->>RedditBlock: get_me
    RedditBlock->>RedditAPI: GET /api/v1/me
    RedditAPI-->>RedditBlock: user profile
    RedditBlock-->>User: id, name, karma, etc.

    User->>RedditBlock: get_user (username)
    RedditBlock->>RedditAPI: GET /user/{username}/about
    RedditAPI-->>RedditBlock: public profile
    RedditBlock-->>User: id, name, karma, etc.

    User->>RedditBlock: send_message (to, subject, text)
    RedditBlock->>RedditAPI: POST /api/compose
    RedditAPI-->>RedditBlock: success/errors
    RedditBlock-->>User: success, message

    User->>RedditBlock: get_messages (where, limit)
    RedditBlock->>RedditAPI: GET /message/{where}
    RedditAPI-->>RedditBlock: listing
    RedditBlock-->>User: messages[], after, before

    User->>RedditBlock: get_subreddit_info (subreddit)
    RedditBlock->>RedditAPI: GET /r/{subreddit}/about
    RedditAPI-->>RedditBlock: subreddit data
    RedditBlock-->>User: subscribers, description, etc.

    Note over SlackBlock: New Slack view tools
    User->>SlackBlock: open_view (triggerId, view)
    SlackBlock->>SlackAPI: POST views.open
    SlackAPI-->>SlackBlock: view object
    SlackBlock-->>User: view { id, hash, blocks, ... }

    User->>SlackBlock: update_view (viewId/externalId, view)
    SlackBlock->>SlackAPI: POST views.update
    SlackAPI-->>SlackBlock: updated view object
    SlackBlock-->>User: view { id, hash, blocks, ... }

    User->>SlackBlock: push_view (triggerId, view)
    SlackBlock->>SlackAPI: POST views.push
    SlackAPI-->>SlackBlock: pushed view object
    SlackBlock-->>User: view { id, hash, blocks, ... }

    User->>SlackBlock: publish_view (userId, view)
    SlackBlock->>SlackAPI: POST views.publish
    SlackAPI-->>SlackBlock: home tab view
    SlackBlock-->>User: view { id, hash, blocks, ... }
Loading

Comments Outside Diff (2)

  1. apps/sim/tools/reddit/get_posts.ts, line 144-180 (link)

    Missing error handling for non-OK responses

    Unlike the other Reddit tools (e.g., get_messages.ts, get_user.ts), getPostsTool.transformResponse never checks response.ok before attempting to extract post data. When the Reddit API returns a 4xx/5xx response (e.g., private subreddit, rate-limit, invalid token), data.data?.children will be undefined, the tool returns success: true with an empty posts array, and the actual error message is silently discarded.

  2. apps/docs/content/docs/en/tools/slack.mdx, line 486 (link)

    Incorrect view type in slack_publish_view output docs

    The type field description for the slack_publish_view output says "modal", but views.publish always returns a view with type = "home". This same inaccuracy appears at the equivalent line in the slack_publish_view output section.

Last reviewed commit: 127968d

Comment on lines +73 to +91
body: (params: SlackUpdateViewParams) => {
const body: Record<string, unknown> = {
view: typeof params.view === 'string' ? JSON.parse(params.view) : params.view,
}

if (params.viewId) {
body.view_id = params.viewId.trim()
}

if (params.externalId) {
body.external_id = params.externalId.trim()
}

if (params.hash) {
body.hash = params.hash.trim()
}

return body
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing runtime validation: both viewId and externalId are optional

Both viewId and externalId are declared required: false, but the Slack views.update API requires at least one of them. There is no guard to throw before sending the request. A call with neither field populated will reach Slack and return an invalid_arguments error — this could be caught earlier with a clear error message.

Suggested change
body: (params: SlackUpdateViewParams) => {
const body: Record<string, unknown> = {
view: typeof params.view === 'string' ? JSON.parse(params.view) : params.view,
}
if (params.viewId) {
body.view_id = params.viewId.trim()
}
if (params.externalId) {
body.external_id = params.externalId.trim()
}
if (params.hash) {
body.hash = params.hash.trim()
}
return body
},
body: (params: SlackUpdateViewParams) => {
if (!params.viewId && !params.externalId) {
throw new Error('Either viewId or externalId is required to update a view.')
}
const body: Record<string, unknown> = {
view: typeof params.view === 'string' ? JSON.parse(params.view) : params.view,
}
if (params.viewId) {
body.view_id = params.viewId.trim()
}
if (params.externalId) {
body.external_id = params.externalId.trim()
}
if (params.hash) {
body.hash = params.hash.trim()
}
return body
},

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.

1 participant