fix: list_published returns empty because it queries drafts endpoint instead of published posts#6
Open
joseprendergast wants to merge 1 commit into
Conversation
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>
0a4bc9c to
973c126
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What's broken
list_published()was callingget_drafts()and filtering results by whetherpost_datewas 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
get_published_posts()toAPIWrapper— wrapsclient.get_published_posts()from thepython-substacklibrary, handles its{'posts': [...]}dict response format, and applies standard error handling.list_published()inPostHandlerto callself.client.get_published_posts(limit=limit)directly.Tests
Added two unit tests:
test_list_published_uses_published_endpoint— assertsget_published_postsis called andget_draftsis nottest_list_published_respects_limit— asserts limit is passed through correctlyNotes
list_drafts— that path is unchangedget_subscriber_counthas a separate issue (KeyError: 'subscriberCount'when the API response doesn't include that field) — left for a follow-up🤖 Generated with Claude Code