feat(reddit): add 5 new tools, fix bugs, and audit all endpoints against API docs#3434
Conversation
PR SummaryMedium Risk Overview Updates existing listing tools to better match Reddit’s API: adds Fixes/adjusts write operations and validation: corrects Written by Cursor Bugbot for commit 0f6b08d. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR expands the Reddit integration from 12 to 17 operations by adding 5 new tools ( Well-implemented additions:
Critical issue:
This inconsistency means auth failures, rate limits, and permissions errors are silently swallowed in listing/write operations while correctly surfaced in the new tools, creating a fragile and confusing user experience. Confidence Score: 2/5
Sequence DiagramsequenceDiagram
participant WF as Workflow Node
participant Block as Reddit Block
participant Tool as Reddit Tool
participant API as Reddit OAuth API
WF->>Block: execute(operation, params)
Block->>Block: toolMap[operation] → tool id
Block->>Block: params() → typed params
alt GET tools (get_me, get_user, get_subreddit_info, get_messages)
Block->>Tool: invoke(params)
Tool->>Tool: validate input (validatePathSegment / validateEnum)
Tool->>API: GET /api/v1/me OR /user/{username}/about OR /r/{sub}/about OR /message/{where}
API-->>Tool: Response
alt response.ok
Tool->>Tool: transformResponse → success: true, output
else !response.ok (401/403/404/429)
Tool->>Tool: transformResponse → success: false, empty output
end
Tool-->>WF: ToolResponse
else POST tools (send_message, reply)
Block->>Tool: invoke(params)
Tool->>API: POST /api/compose OR /api/comment
API-->>Tool: Response
alt !response.ok
Tool->>Tool: HTTP error → success: false
else data.json.errors present
Tool->>Tool: API error → success: false
else success
Tool->>Tool: success: true, message
end
Tool-->>WF: ToolResponse
else Listing tools (get_posts, get_controversial, search, hot_posts, get_comments)
Block->>Tool: invoke(params)
Tool->>API: GET /r/{sub}/{sort} OR /r/{sub}/search OR /r/{sub}/comments/{id}
API-->>Tool: Response
Note over Tool: ⚠️ No response.ok check!
Tool->>Tool: data.data?.children?.map() || []
Tool-->>WF: success: true (even on 401/403/429)
end
|
- 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
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.
|
@greptile |
|
@cursor review |
- Add validateEnum/validatePathSegment to prevent URL path traversal - Add !response.ok guards to send_message and reply tools - Centralize subreddit validation in normalizeSubreddit
|
@greptile |
|
@cursor review |
|
@greptile |
Summary
Type of Change
Testing
Tested manually
Checklist