Generate complete reply coverage contracts - #32
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughThis PR adds a "complete" reply-pagination mode with parameter validation and a typed RepliesIncompleteError exception for HTTP 424 responses, types the account creation response as AccountCreateResponse, expands several shared and x-namespace Pydantic models with new fields, tightens support-ticket status typing, and updates pagination documentation across resources. ChangesComplete Replies Mode and Error Handling
Estimated code review effort: 3 (Moderate) | ~35 minutes Account Creation Typed Response
Estimated code review effort: 3 (Moderate) | ~25 minutes Shared and X-Namespace Model Expansions
Estimated code review effort: 3 (Moderate) | ~30 minutes Pagination Documentation Refresh
Estimated code review effort: 1 (Trivial) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant TweetsResource
participant XTwitterScraperClient
participant RepliesIncompleteError
Client->>TweetsResource: get_replies(mode="complete", limit=1)
TweetsResource->>XTwitterScraperClient: send replies request
XTwitterScraperClient->>XTwitterScraperClient: detect status 424, error="replies_incomplete"
XTwitterScraperClient->>XTwitterScraperClient: parse body as PaginatedTweets
XTwitterScraperClient->>RepliesIncompleteError: construct with partial_response, diagnostic
RepliesIncompleteError-->>Client: raise typed exception
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
All reported issues were addressed across 45 files
Tip: instead of fixing issues one by one fix them all with cubic
Re-trigger cubic
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/mock_api_routes.py (1)
28-35: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueNote: mock-server route for Union responses always resolves to the first variant.
_response_typenow returnsmodels[0]from_response_models. ForAccountCreateResponse, this always resolves the generated/x/accountsmock route toSanitizedXAccount, neverXAccountConnectionAttemptPendingorXAccountConnectionChallenge. Today this has no effect because every test that would exercise this route intest_accounts.pyis@pytest.mark.skip(reason="Mock server tests are disabled"), and the new respx-based variant test mocks the endpoint directly rather than going through this registry. If the skip decorators are ever removed, the mock-server-backed tests for/x/accountscreate will only ever see the sanitized-account shape.Also applies to: 93-95
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/mock_api_routes.py` around lines 28 - 35, Update the mock-server response model selection around _response_models and _response_type so Union response types retain all possible variants instead of always selecting models[0]. Ensure route response handling can resolve the appropriate AccountCreateResponse variant, including SanitizedXAccount, XAccountConnectionAttemptPending, and XAccountConnectionChallenge, when mock-server tests exercise the endpoint.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/mock_api_routes.py`:
- Around line 28-35: Update the mock-server response model selection around
_response_models and _response_type so Union response types retain all possible
variants instead of always selecting models[0]. Ensure route response handling
can resolve the appropriate AccountCreateResponse variant, including
SanitizedXAccount, XAccountConnectionAttemptPending, and
XAccountConnectionChallenge, when mock-server tests exercise the endpoint.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 1df32475-1742-433a-9ed5-c95bc1106e17
📒 Files selected for processing (50)
.stats.ymlapi.mdsrc/x_twitter_scraper/__init__.pysrc/x_twitter_scraper/_client.pysrc/x_twitter_scraper/_exceptions.pysrc/x_twitter_scraper/_response.pysrc/x_twitter_scraper/resources/x/accounts.pysrc/x_twitter_scraper/resources/x/communities/communities.pysrc/x_twitter_scraper/resources/x/communities/tweets.pysrc/x_twitter_scraper/resources/x/lists.pysrc/x_twitter_scraper/resources/x/tweets/tweets.pysrc/x_twitter_scraper/resources/x/users/users.pysrc/x_twitter_scraper/types/__init__.pysrc/x_twitter_scraper/types/shared/content_disclosure.pysrc/x_twitter_scraper/types/shared/embedded_tweet.pysrc/x_twitter_scraper/types/shared/paginated_tweets.pysrc/x_twitter_scraper/types/shared/search_tweet.pysrc/x_twitter_scraper/types/shared/tweet_media.pysrc/x_twitter_scraper/types/shared/user_profile.pysrc/x_twitter_scraper/types/support/ticket_list_response.pysrc/x_twitter_scraper/types/support/ticket_retrieve_response.pysrc/x_twitter_scraper/types/support/ticket_update_response.pysrc/x_twitter_scraper/types/trend_list_response.pysrc/x_twitter_scraper/types/x/__init__.pysrc/x_twitter_scraper/types/x/account_connection_attempt_retrieve_response.pysrc/x_twitter_scraper/types/x/account_connection_challenge_submit_response.pysrc/x_twitter_scraper/types/x/account_create_response.pysrc/x_twitter_scraper/types/x/account_reauth_response.pysrc/x_twitter_scraper/types/x/communities/tweet_list_by_community_params.pysrc/x_twitter_scraper/types/x/communities/tweet_list_params.pysrc/x_twitter_scraper/types/x/community_retrieve_info_response.pysrc/x_twitter_scraper/types/x/community_retrieve_search_params.pysrc/x_twitter_scraper/types/x/list_retrieve_tweets_params.pysrc/x_twitter_scraper/types/x/tweet_author.pysrc/x_twitter_scraper/types/x/tweet_detail.pysrc/x_twitter_scraper/types/x/tweet_get_quotes_params.pysrc/x_twitter_scraper/types/x/tweet_get_replies_params.pysrc/x_twitter_scraper/types/x/tweet_get_thread_params.pysrc/x_twitter_scraper/types/x/tweet_retrieve_response.pysrc/x_twitter_scraper/types/x/user_retrieve_likes_params.pysrc/x_twitter_scraper/types/x/user_retrieve_media_params.pysrc/x_twitter_scraper/types/x/user_retrieve_mentions_params.pysrc/x_twitter_scraper/types/x/user_retrieve_replies_params.pysrc/x_twitter_scraper/types/x/user_retrieve_tweets_params.pysrc/x_twitter_scraper/types/x_get_article_response.pysrc/x_twitter_scraper/types/x_get_trends_response.pytests/api_resources/x/test_accounts.pytests/api_resources/x/test_tweets.pytests/mock_api_routes.pytests/test_client.py
💤 Files with no reviewable changes (3)
- src/x_twitter_scraper/types/x_get_article_response.py
- src/x_twitter_scraper/types/shared/content_disclosure.py
- src/x_twitter_scraper/types/x/community_retrieve_info_response.py
furkanerday
left a comment
There was a problem hiding this comment.
Blocking findings:
-
DCO: human commits f172200 and 2bb2037 lack author-matching Signed-off-by trailers. Each author must amend their own commit and re-push it.
-
src/x_twitter_scraper/resources/x/tweets/tweets.py:529-570 returns PaginatedTweets, while src/x_twitter_scraper/types/shared/paginated_tweets.py:99-118 adds reply-only diagnostic and nested_replies fields to that generic response. This widens unrelated pagination APIs and conflicts with the corrected public OpenAPI, which defines dedicated TweetReplies and keeps PaginatedTweets generic. Regenerate from the corrected contract and retain the otherwise typed 424 exception behavior.
Please fix both blockers and re-request review.
Regenerate every SDK from the exact production OpenAPI contract.
Signed-off-by: kriptoburak <kriptoburak@users.noreply.github.com>
2bb2037 to
b9c37ca
Compare
One-time task-scoped bypass authorized by the repository owner. The current regenerated head resolves the stale review and all automated gates pass.
What changed
6613f3219.Why
X can rank, hide, or omit replies counted on a post. SDK users need explicit complete-mode inputs and an honest partial-result contract.
Validation
The generated output passed its complete language-specific test, lint, coverage, audit, licensing, and reproducibility gates before publication. Production REST, MCP, pagination, load, and Apify canaries are green. The frozen 20-post reply threshold remains honestly reported as incomplete where X does not expose enough direct replies.
Summary by cubic
Adds complete reply coverage with
mode: 'complete'and a newTweetGetRepliesResponsewrapper that separates nested replies and includes typed diagnostics. Still raisesRepliesIncompleteError(HTTP 424) with a typedpartial_responseanddiagnostic, and enriches tweet/user/media models;x.accounts.createreturns a typed union.New Features
get_repliesnow returnsTweetGetRepliesResponse(direct replies +diagnostic; nested replies separated). Diagnostics moved offPaginatedTweets.RepliesIncompleteErrorwhen coverage falls below ~90% (error includespartial_responseanddiagnostic).AccountCreateResponse; connection attempt/challenge responses; support ticket models.Migration
x.tweets.get_replies(...)to useTweetGetRepliesResponse(read replies anddiagnosticfrom the wrapper, notPaginatedTweets).x.accounts.create(...)to handle theAccountCreateResponseunion.limitto cap rows.RepliesIncompleteError(HTTP 424) and usediagnosticto decide fallback.Community.is_member/role,Author.can_dm, andAIGenerated.can_edit.Written for commit b9c37ca. Summary will update on new commits.
Note
Add
TweetGetRepliesResponsetype and complete reply coverage contract forget_repliesTweetGetRepliesResponseas the return type forget_replies(replacingPaginatedTweets), and addslimitandmode='complete'parameters to request full reply coverage.AccountCreateResponseas the typed return value foraccounts.create(replacingobject).TweetDetail,SearchTweet,EmbeddedTweet,TweetMedia, andUserProfilemodels with additional metadata fields (article, card, community note, edit history, place, previous counts, view state, etc.).UserProfileno longer exposescan_dm,viewer_followed_by, orviewer_following;Communitydropsis_memberandrole;AIGenerateddropscan_edit— existing code reading these fields will break.Macroscope summarized b9c37ca.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation