Skip to content

Conversation

@UcnacDx2
Copy link
Contributor

@UcnacDx2 UcnacDx2 commented Jan 14, 2026

Description / 描述

有用户报告称,遇到登陆问题,返回错误信息如下:
Failed init storage: login with password failed: failed to extract sid or cguid from login response

经查,目前 139 云盘驱动在处理初始化登录时存在逻辑闭环缺陷:

  1. 重复登录触发风控: 驱动在已有有效 a_l/a_l2 令牌的情况下,仍会尝试执行 password_login(密码登录),导致短时间内频繁错误请求请求移动登录接口,触发 ec=PML401010062(频率限制/风控)错误。
  2. 非法状态请求: 在请求登录接口(Login.ashx)时,如果 Header 携带了旧的 a_l/a_l2 令牌等,会触发服务器的安全保护机制,导致重定向链接中缺失 sid 参数。

Motivation and Context / 背景

Relates to #XXXX

How Has This Been Tested? / 测试

填入如下不同状态189mail cookie
①未进行设备认证
②已经进行设备认证,且处于登录状态
③已经进行设备认证,且处于注销状态

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

google-labs-jules bot and others added 2 commits January 14, 2026 12:15
- Implemented a pre-auth validation check to prevent unnecessary logins when a valid session token exists.
- Enhanced header sanitization to separate device fingerprint from session tokens, preventing login failures.
- Added risk control handling to detect and stop login attempts when rate-limited.
fix(139yun): Address login logic loop defect
Copilot AI review requested due to automatic review settings January 14, 2026 12:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

google-labs-jules bot and others added 7 commits January 14, 2026 13:27
- Implemented a pre-auth validation check to prevent unnecessary logins when a valid session token exists.
- Enhanced header sanitization to separate device fingerprint from session tokens, preventing login failures.
- Added risk control handling to detect and stop login attempts when rate-limited.
- Ensured a fixed order for sanitized cookies as per PR feedback.
- Implemented a pre-auth validation check to prevent unnecessary logins when a valid session token exists.
- Enhanced header sanitization to separate device fingerprint from session tokens, preventing login failures.
- Added risk control handling to detect and stop login attempts when rate-limited.
- Ensured a fixed order for sanitized cookies as per PR feedback.
- Improved pre-auth error handling to correctly differentiate between network errors and blocked redirects.
- Implemented a pre-auth validation check to prevent unnecessary logins when a valid session token exists.
- Enhanced header sanitization to separate device fingerprint from session tokens, preventing login failures.
- Added risk control handling to detect and stop login attempts when rate-limited.
- Ensured a fixed order for sanitized cookies as per PR feedback.
- Improved pre-auth error handling to correctly differentiate between network errors and blocked redirects.
- Formatted code with `go fmt`.
- Implemented a pre-auth validation check to prevent unnecessary logins when a valid session token exists.
- Enhanced header sanitization to separate device fingerprint from session tokens, preventing login failures.
- Added risk control handling to detect and stop login attempts when rate-limited.
- Ensured a fixed order for sanitized cookies as per PR feedback.
- Improved pre-auth error handling to correctly differentiate between network errors and blocked redirects.
- Formatted code with `go fmt`.
- Added validation for MailCookies format to prevent invalid requests.
- Implemented a pre-auth validation check to prevent unnecessary logins when a valid session token exists.
- Enhanced header sanitization to separate device fingerprint from session tokens, preventing login failures.
- Added risk control handling to detect and stop login attempts when rate-limited.
- Ensured a fixed order for sanitized cookies as per PR feedback.
- Improved pre-auth error handling to correctly differentiate between network errors and blocked redirects.
- Formatted code with `go fmt`.
- Added validation for MailCookies format to prevent invalid requests.
- Refactored the `request` function to remove goto and reduce nesting.
- Implemented a pre-auth validation check to prevent unnecessary logins when a valid session token exists.
- Enhanced header sanitization to separate device fingerprint from session tokens, preventing login failures.
- Added risk control handling to detect and stop login attempts when rate-limited.
- Ensured a fixed order for sanitized cookies as per PR feedback.
- Improved pre-auth error handling to correctly differentiate between network errors and blocked redirects.
- Formatted code with `go fmt`.
- Added validation for MailCookies format to prevent invalid requests.
- Refactored the `request` function to remove goto and reduce nesting.
Fix 139 yun login loop
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

google-labs-jules bot and others added 4 commits January 14, 2026 14:32
This commit addresses several issues in the 139 driver, including:
- A concurrency issue in preAuthLogin by creating a new resty client instance.
- Removal of sensitive data from logs to prevent credential exposure.
- Improved MailCookies validation to ensure it contains at least one name=value pair.
- Corrected an inaccurate error message for better accuracy.
- Clarified the sanitizeLoginCookies function with a comment.
- Standardized error handling in preAuthLogin to allow a fallback to password login.
- Fixed a mixed-language comment for consistency.
- Strengthened a fragile error check by examining the underlying error type.
This commit addresses a concurrency issue that occurred when creating multiple instances of the 139 driver. The issue was caused by modifying the global `resty` client's redirect policy, which is not thread-safe.

This commit fixes the issue by:
- Creating a new `resty` client instance in `step1_password_login` to avoid modifying the global client.
- Reverting a previous change to the error handling in `preAuthLogin` that was incorrect.

These changes ensure that each driver instance has its own `resty` client, preventing race conditions and allowing multiple instances of the driver to be created without errors.
This commit fixes a regression where the `RMKEY` cookie was not being
correctly extracted from the login response. This was caused by a
previous change that switched to a local `resty` client but did not
update the cookie extraction logic.

This commit fixes the issue by:
- Correctly parsing the cookies from the HTTP response.
- Merging the new cookies with the existing `MailCookies`.

This ensures that the `RMKEY` is properly saved and used in subsequent
steps, allowing the login process to complete successfully.
fix(drivers/139): Address multiple issues in 139 driver
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +764 to +789
orderedCookieNames := []string{
"behaviorid",
"Os_SSo_Sid",
"_139_index_isLoginType",
"_139_login_version",
"Login_UserNumber",
"cookiepartid8011",
"_139_login_agreement",
"UserData",
"rmUin8011",
"cookiepartid",
"UUIDToken",
"SkinPath28011",
"cbauto",
"areaCode8011",
"cookieLen",
"DEVICE_INFO_DIGEST",
"JSESSIONID",
"loginProcessFlag",
"provCode8011",
"S_DEVICE_TOKEN",
"taskIdCloud",
"UserNowState",
"UserNowState8011",
"ut8011",
}
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sanitizeLoginCookies function doesn't filter out authentication tokens like "a_l" and "a_l2" from the allowlist. According to the PR description, the problem is that carrying old a_l/a_l2 tokens in the login request triggers security protection. However, these tokens are not in the orderedCookieNames list, so they won't be included in the sanitized output. This appears to be working as intended, but it would be helpful to add a comment explaining that authentication tokens are intentionally excluded to prevent triggering security controls.

Copilot uses AI. Check for mistakes.
}
}

if resp.StatusCode() == 302 {
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a potential nil pointer dereference issue. If the request at line 1331 fails with a non-redirect error, the response object resp might be nil when checking resp.StatusCode() at line 1343. The code should verify that resp is not nil before accessing its methods.

Copilot uses AI. Check for mistakes.
Copilot AI and others added 4 commits January 14, 2026 16:38
…nd enforce password validation

Optimize 139 driver login flow - eliminate unnecessary HTTP request and enforce password validation
@xrgzs xrgzs changed the title fix(139yun): Address login logic loop defect fix(drivers/139): Address login logic loop defect Jan 15, 2026
@xrgzs xrgzs added bug Module: Driver Driver-Related Issue/PR labels Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Module: Driver Driver-Related Issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants