Summary
With xdk 0.10.6, reading a timeline that contains a repost raises pydantic.ValidationError, and the whole page is lost. When a request uses post.fields=referenced_posts, the API returns "type": "reposted". PostReferencedPostsItem.type only allows Literal["retweeted", "quoted", "replied_to"].
Reproduction
The same repost, fetched with the old and new field vocabularies (raw HTTP, app-only bearer token):
GET /2/tweets/{repost_id}?tweet.fields=referenced_tweets
→ "referenced_tweets": [{"id": "...", "type": "retweeted"}]
GET /2/tweets/{repost_id}?post.fields=referenced_posts
→ "referenced_posts": [{"id": "...", "type": "reposted"}]
Through the SDK:
from xdk import Client
client = Client(bearer_token=BEARER)
page = next(iter(client.lists.get_posts(LIST_ID, max_results=20,
post_fields=["referenced_posts"],
expansions=["referenced_posts.id"])))
pydantic_core._pydantic_core.ValidationError: 8 validation errors for GetListsPostsResponse
data.0.referenced_posts.0.type
Input should be 'retweeted', 'quoted' or 'replied_to' [type=literal_error, input_value='reposted', input_type=str]
Cause
The published OpenAPI spec (https://api.x.com/2/openapi.json, info.version 2.168) still lists retweeted | quoted | replied_to for PostReferencedPosts.items.type and never mentions reposted. The generated model matches the spec, but the live API has moved on.
Suggested fix
- Add
reposted to the enum in the spec (and so in the generated model).
- More generally, consider leaving response enums open (e.g.
str, or Literal[...] | str). As it stands, one new value from the server fails every page that contains it, not just the affected field.
Environment
- xdk 0.10.6 (latest on PyPI), Python 3.12, pydantic 2.13
- Affects
lists.get_posts, users.get_bookmarks, users.get_posts, and posts.get_by_id: any response that includes referenced_posts.
Summary
With xdk 0.10.6, reading a timeline that contains a repost raises
pydantic.ValidationError, and the whole page is lost. When a request usespost.fields=referenced_posts, the API returns"type": "reposted".PostReferencedPostsItem.typeonly allowsLiteral["retweeted", "quoted", "replied_to"].Reproduction
The same repost, fetched with the old and new field vocabularies (raw HTTP, app-only bearer token):
Through the SDK:
Cause
The published OpenAPI spec (
https://api.x.com/2/openapi.json,info.version2.168) still listsretweeted | quoted | replied_toforPostReferencedPosts.items.typeand never mentionsreposted. The generated model matches the spec, but the live API has moved on.Suggested fix
repostedto the enum in the spec (and so in the generated model).str, orLiteral[...] | str). As it stands, one new value from the server fails every page that contains it, not just the affected field.Environment
lists.get_posts,users.get_bookmarks,users.get_posts, andposts.get_by_id: any response that includesreferenced_posts.