Skip to content

fix(social): correct search_social_posts response parsing - #21

Open
appressman wants to merge 2 commits into
mastanley13:mainfrom
appressman:main
Open

fix(social): correct search_social_posts response parsing#21
appressman wants to merge 2 commits into
mastanley13:mainfrom
appressman:main

Conversation

@appressman

@appressman appressman commented Jun 17, 2026

Copy link
Copy Markdown

Problem

search_social_posts always returns an empty list (count: 0, posts: []) regardless of what's in the Social Planner.

Root Cause

The POST /social-media-posting/{locationId}/posts/list endpoint wraps its response under a results key:

{ "results": { "posts": [...], "total": 99 } }

The tool was reading response.data?.posts directly, which is always undefined — so every search silently returns nothing.

Fix

  • src/tools/social-media-tools.ts — reads response.data?.results?.posts with fallback to response.data?.posts for backwards compatibility
  • src/types/ghl-types.ts — added results?: { posts, total } to GHLSearchPostsResponse to match the actual API shape

Tested against a live GHL location — confirmed 99 published posts returned correctly after the fix.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Chores
    • Added server configuration framework
    • Enhanced social media search to handle multiple response formats for improved reliability

Eve (PAI Digital Assistant) and others added 2 commits March 16, 2026 17:16
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The /posts/list API returns results nested under a `results` key
({ results: { posts, total } }) but the tool was reading response.data.posts
directly, always resolving to undefined and returning an empty list.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dd64970e-3071-4f5a-9fbd-6f19e7af207f

📥 Commits

Reviewing files that changed from the base of the PR and between 1af0524 and f1fcaf8.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • .mcp.json
  • src/tools/social-media-tools.ts
  • src/types/ghl-types.ts

📝 Walkthrough

Walkthrough

GHLSearchPostsResponse is updated to make posts and count optional and to add an optional results wrapper with posts and total. searchSocialPosts is updated to extract those fields from either the nested or top-level shape. A new empty .mcp.json configuration file is also added.

Changes

Social Search Response Normalization

Layer / File(s) Summary
Response type and normalization logic
src/types/ghl-types.ts, src/tools/social-media-tools.ts
GHLSearchPostsResponse adds an optional results?: { posts, total } field and makes top-level posts and count optional. searchSocialPosts resolves posts from response.data.results.posts or response.data.posts (fallback []), and count from response.data.results.total, response.data.count, or posts.length.

MCP Configuration

Layer / File(s) Summary
Empty MCP servers config
.mcp.json
New file defining a top-level mcpServers object initialized to {}.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐇 Two shapes of reply, who knows which will come?
The rabbit checks both — neither leaves results numb.
results.posts or plain posts, fallback to none,
count follows the total when nesting is done.
A blank MCP config sits quietly too,
Ready for servers whenever they're due! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(social): correct search_social_posts response parsing' accurately describes the main fix: correcting response parsing in the search_social_posts function for the social media tools.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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