Skip to content

fix: list_published returns empty because it queries drafts endpoint instead of published posts#6

Open
joseprendergast wants to merge 1 commit into
ty13r:mainfrom
joseprendergast:fix/list-published-uses-wrong-endpoint
Open

fix: list_published returns empty because it queries drafts endpoint instead of published posts#6
joseprendergast wants to merge 1 commit into
ty13r:mainfrom
joseprendergast:fix/list-published-uses-wrong-endpoint

Conversation

@joseprendergast
Copy link
Copy Markdown

What's broken

list_published() was calling get_drafts() and filtering results by whether post_date was set. The drafts API only returns unpublished content, so published posts are never included — the tool always returns an empty list.

Confirmed by testing against a live Substack account with 5 published posts.

Fix

  1. Added get_published_posts() to APIWrapper — wraps client.get_published_posts() from the python-substack library, handles its {'posts': [...]} dict response format, and applies standard error handling.
  2. Updated list_published() in PostHandler to call self.client.get_published_posts(limit=limit) directly.

Tests

Added two unit tests:

  • test_list_published_uses_published_endpoint — asserts get_published_posts is called and get_drafts is not
  • test_list_published_respects_limit — asserts limit is passed through correctly

Notes

  • No behavior change for list_drafts — that path is unchanged
  • get_subscriber_count has a separate issue (KeyError: 'subscriberCount' when the API response doesn't include that field) — left for a follow-up

🤖 Generated with Claude Code

list_published() was calling get_drafts() and filtering by post_date,
which returns 0 results because the drafts API only returns unpublished
content. Fixed by adding get_published_posts() to APIWrapper (wrapping
the library's get_published_posts method, handling its dict response
format) and updating list_published() to call it directly.

Added two unit tests to prevent regression.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@joseprendergast joseprendergast force-pushed the fix/list-published-uses-wrong-endpoint branch from 0a4bc9c to 973c126 Compare April 17, 2026 01:55
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