Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(route/twitter): Prevent storing empty cookie if obtaining such from auth_token failed. #17232

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

dzx-dzx
Copy link
Contributor

@dzx-dzx dzx-dzx commented Oct 21, 2024

Involved Issue / 该 PR 相关 Issue

Close #

Example for the Proposed Route(s) / 路由地址示例

/twitter/user/DIYgod

New RSS Route Checklist / 新 RSS 路由检查表

  • New Route / 新的路由
  • Anti-bot or rate limit / 反爬/频率限制
    • If yes, do your code reflect this sign? / 如果有, 是否有对应的措施?
  • Date and time / 日期和时间
    • Parsed / 可以解析
    • Correct time zone / 时区正确
  • New package added / 添加了新的包
  • Puppeteer

Note / 说明

@github-actions github-actions bot added Route Auto: Route Test Complete Auto route test has finished on given PR labels Oct 21, 2024
Copy link
Contributor

Successfully generated as following:

http://localhost:1200/twitter/user/DIYgod - Failed ❌
HTTPError: Response code 503 (Service Unavailable)

Error Message:<br/>ConfigNotFoundError: Twitter API is not configured
Route: /twitter/user/:id/:routeParams?
Full Route: /twitter/user/DIYgod
Node Version: v22.10.0
Git Hash: 0831b15b

@pseudoyu pseudoyu force-pushed the master branch 5 times, most recently from 8ef9ae7 to d224d67 Compare October 31, 2024 11:39
@TonyRL TonyRL merged commit 2eef201 into DIYgod:master Oct 31, 2024
27 checks passed
@AiraNadih
Copy link
Contributor

AiraNadih commented Oct 31, 2024

This commit broke the Twitter routes on RSSHub instances that authenticate using auth_token.

I suspect the issue might be here:

cache.set(`twitter:cookie:${token}`, cookie);

@dzx-dzx
Copy link
Contributor Author

dzx-dzx commented Nov 1, 2024

@AiraNadih It works on my side. What error messages are given?

@AiraNadih
Copy link
Contributor

@AiraNadih It works on my side. What error messages are given?

Error in /twitter/home/onlyMedia=1: ConfigNotFoundError: Twitter cookie for token *** is not valid

@dzx-dzx
Copy link
Contributor Author

dzx-dzx commented Nov 1, 2024

I don't think the token method is stable, even before this pr. Please try a few times more.

@AiraNadih
Copy link
Contributor

AiraNadih commented Nov 1, 2024

I don't think the token method is stable, even before this pr. Please try a few times more.

But after I rolled back to commit 682c943, it was normal.

I'm currently using this commit node's Docker image.

@AiraNadih
Copy link
Contributor

I just tested it again.
Including the two times I tested it when I commented before, that's a total of three times now.

The first request after initial deployment is normal, but subsequent requests will result in errors.

Rolling back to the previous commit works correctly.
Therefore, I am certain that some part of this commit must have broken the relevant logic.

@flameleaf
Copy link
Contributor

flameleaf commented Nov 1, 2024

One strange quirk I've noticed about the auth_token cookie is that quoting the variable sometimes fixes it. It'll randomly fail on my deployment, but if I change it from TWITTER_AUTH_TOKEN=token_name to TWITTER_AUTH_TOKEN='token_name', or vice-versa, it'll return to a usable state.

EDIT: It could just be the fact that I'm modifying the variable and giving it time to restart that's helping the instance re-stabilize. Point is, this behavior has been ongoing since RSSHub switched to using the TWITTER_AUTH_TOKEN config, before and after this pull request was merged, at least on my deployment.

@AiraNadih
Copy link
Contributor

Seeing the latest merged PR #17429, I finally understand where the problem lies.

artefaritaKuniklo pushed a commit to artefaritaKuniklo/RSSHub that referenced this pull request Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto: Route Test Complete Auto route test has finished on given PR Route
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants