Skip to content

fix: Twitter API error (HTTP 404) #39#40

Closed
stoneidolon wants to merge 1 commit intojackwener:mainfrom
stoneidolon:fix-ondemand-url-none-check
Closed

fix: Twitter API error (HTTP 404) #39#40
stoneidolon wants to merge 1 commit intojackwener:mainfrom
stoneidolon:fix-ondemand-url-none-check

Conversation

@stoneidolon
Copy link

When get_ondemand_file_url() fails to extract the ondemand file URL from the homepage (due to page structure changes or access restrictions), it returns None. Previously, this None was passed directly to the HTTP request, causing a confusing 'NoneType' object has no attribute 'split' error.

Now we explicitly check for None and raise a clear error message: "Failed to extract ondemand file URL from homepage"

Also added unit tests to verify:

  • None URL is handled gracefully without crashing
  • Normal flow works when URL is valid

When get_ondemand_file_url() fails to extract the ondemand file URL
from the homepage (due to page structure changes or access restrictions),
it returns None. Previously, this None was passed directly to the HTTP
request, causing a confusing 'NoneType' object has no attribute 'split'
error.

Now we explicitly check for None and raise a clear error message:
"Failed to extract ondemand file URL from homepage"

Also added unit tests to verify:
- None URL is handled gracefully without crashing
- Normal flow works when URL is valid

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jackwener added a commit that referenced this pull request Mar 20, 2026
Twitter migrated SearchTimeline from GET to POST; update fetch_search
to route through _graphql_post via a new use_post flag on _fetch_timeline,
avoiding duplicating the pagination logic (closes #39, refs #40, #42).

Also guard against get_ondemand_file_url returning None so the error
message is clear instead of crashing on NoneType.split (closes #43-adjacent).

Refresh all FALLBACK_QUERY_IDS from live JS bundles — 18 operations updated.
@jackwener
Copy link
Owner

Thanks @stoneidolon for identifying the None URL issue and adding tests! The guard is now in place in 199a149 — I used raise ValueError so the existing except Exception block in _ensure_client_transaction catches it cleanly and logs a clear warning, which is consistent with the rest of the error handling style in the codebase.

Really appreciate you also writing unit tests for this — it influenced how I validated the fix! 🙏

@jackwener jackwener closed this Mar 20, 2026
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.

2 participants