Skip to content

Ask for drafts by default in Api.get_drafts - #93

Open
MattFisher wants to merge 1 commit into
ma2za:mainfrom
MattFisher:fix/get-drafts-default-filter
Open

MattFisher wants to merge 1 commit into
ma2za:mainfrom
MattFisher:fix/get-drafts-default-filter

Conversation

@MattFisher

Copy link
Copy Markdown
Contributor

Api.get_drafts() fails with APIError(code=400): Invalid value when called without a filter. This PR makes filter="draft" the default.

The problem

Substack's draft listing endpoint now rejects requests that have no filter parameter:

GET /api/v1/drafts?limit=5
400 {"errors": [{"location": "query", "param": "filter", "msg": "Invalid value"}]}

GET /api/v1/drafts?filter=draft&limit=5
200 {"posts": [...], "hasMore": ..., "nextCursor": ...}

get_drafts() defaults to filter=None, and requests drops None parameters, so the default call always gets the 400. The CLI and the MCP server already pass filter="draft" themselves, so only direct callers of Api.get_drafts() are affected. The repo's own live test test_api.py::ApiTest::test_get_drafts currently fails for this reason.

The change

  • get_drafts(filter="draft", offset=None, limit=None).
  • The docstring says what filter is for.

Callers that pass a filter explicitly behave exactly as before.

Testing

  • New offline test asserting the default request carries filter=draft.
  • pytest -q -m "not live" --strict-markers: 292 passed.
  • Checked against the live API with the requests shown above.

🤖 Generated with Claude Code

Substack's draft listing endpoint now answers 400 "Invalid value" for
the filter parameter when none is sent, so get_drafts() failed unless
the caller passed filter="draft" explicitly. Make that the default.

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

This branch has not been deployed

No deployments
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