fix(x-oauth): resolve user ID before /users/{id}/bookmarks call#72
Open
Bit-Bonds wants to merge 1 commit intoviperrcrypto:mainfrom
Open
fix(x-oauth): resolve user ID before /users/{id}/bookmarks call#72Bit-Bonds wants to merge 1 commit intoviperrcrypto:mainfrom
Bit-Bonds wants to merge 1 commit intoviperrcrypto:mainfrom
Conversation
The X API v2 rejects /users/me/bookmarks with:
{"errors":[{"parameters":{"id":["me"]},
"message":"The id query parameter value [me] is not valid"}],
"title":"Invalid Request"}
Bookmarks must be fetched against the authenticated user's numeric ID,
not the literal string "me". The /tweets endpoints accept "me" as an
alias but /users/{id}/bookmarks does not.
Fix: call /2/users/me first to resolve the numeric ID, then use it for
all subsequent /users/{id}/bookmarks pagination requests. Adds one extra
request per import (negligible compared to the bookmark pagination loop).
Reproduced on a fresh OAuth 2.0 connection on the new pay-per-use
console (X API as of 2026-04). Without this fix, every X OAuth import
fails with "X API error: 400" before fetching any bookmarks.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Review: X OAuth Bookmarks User ID Fix Clean fix for X API compatibility issue. The /users/me/bookmarks endpoint was rejected; now properly resolves the numeric user ID first. Security/Error Handling:
Nit: Consider caching the resolved userId in the session to avoid the extra API call on repeated bookmark fetches in the same session. Not blocking. Test recommendation: Add a mock test for the users/me resolution failure case. LGTM - fixes a real API breakage. |
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.
Summary
/2/users/mebefore calling/2/users/{id}/bookmarksThe bug
app/api/import/x-oauth/fetch/route.tscallshttps://api.x.com/2/users/me/bookmarks?.... The X API v2 rejects this:{ "errors": [{ "parameters": {"id": ["me"]}, "message": "The `id` query parameter value [me] is not valid" }], "title": "Invalid Request", "type": "https://api.twitter.com/2/problems/invalid-request" }The
/users/{id}/bookmarksendpoint requires the numeric user ID — unlike many/2/tweets/*endpoints, it does not acceptmeas an alias.Result: every X OAuth import fails with
"X API error: 400"before any bookmarks are fetched. Reproduced on a brand-new OAuth 2.0 connection on the new pay-per-use developer console (console.x.com) as of April 2026.The fix
Call
/2/users/meonce at the start ofPOST /api/import/x-oauth/fetchto resolve the numeric ID, then use it for all/users/{id}/bookmarkspagination requests. One extra request per import — negligible against the bookmark pagination loop, and/users/medoesn't consume bookmark-list rate limits.Test plan
maxPages: 20)🤖 Generated with Claude Code