Skip to content

fix(bangumi): 网页控制台账号登录修复 app_nonexistence(授权表单 action 为空) - #100

Merged
ModerRAS merged 1 commit into
masterfrom
fix/web-login-authorize-action
Nov 17, 2026
Merged

ModerRAS merged 1 commit into
masterfrom
fix/web-login-authorize-action

Conversation

@ModerRAS

Copy link
Copy Markdown
Owner

现象

网页控制台(WebUI)「元数据 → 使用账号登录」提交邮箱/密码/验证码后,电视端弹裸的 app_nonexistence,无法完成登录。同一个授权 URL 在浏览器里能正常出授权页,说明应用注册、client_id、redirect_uri 都没有问题。

根因

Bangumi 的 /oauth/authorize 授权页渲染的表单没有 action 属性,client_id / response_type / redirect_uri / state 全在页面 URL 的查询串里;浏览器对空 action 表单会「提交回当前 URL」。

BangumiPasswordLoginClient.parseAuthorizeForm() 把空 action 兜底成 "/oauth/authorize",POST 到裸路径后 response_type / state 丢失,Bangumi 判定为无效授权请求,渲染通用错误页 呜咕,出错了 / app_nonexistence。

修复

  • parseAuthorizeForm:保留空 action,不再兜底成 /oauth/authorize;
  • loginAndAuthorize:action 为空时直接回提交到授权页 URL(带查询串);action 非空时按浏览器语义相对授权页 URL 解析(新增 resolveAgainst);
  • 单测 fixture 改成线上形态(无 action),并新增回归断言:authorize POST 必须带 client_id / response_type / state 查询串。

验证

协议层(真实站点 + 测试账号 + 发版包内置凭据,走电视同一条出站代理)

请求 结果
POST 裸 /oauth/authorize(修复前行为) 200 + app_nonexistence
POST 带查询串的授权页 URL(浏览器行为) 302 → 回环 callback?code=…&state=…
用 code + 客户端凭据换 token 200,access_token 7 天 + refresh_token

Android TV 真机(debug 包注入发版凭据)

/start  → challenge + captcha
submit  → status=success(message: Bangumi 登录成功。),tokenConfigured=true
/api/metadata → bangumiTokenConfigured=true

单测::scraper-core:test 5/5 绿;回退主代码改动后 2 个用例红(回归有效)。

说明 / 未覆盖

  • TV 端 WebView 登录(真实浏览器)路径不受影响;
  • 授权页若以后改成带 action 的形态,仍按浏览器语义解析,行为不变;
  • 已发布版本仍是旧代码,需要发版后才能复测线上。

Bangumi 的 /oauth/authorize 表单没有 action 属性,client_id/response_type/redirect_uri/state 都在页面 URL 的查询串里;浏览器会把空 action 表单提交回当前 URL。原来的解析把空 action 兜底成 /oauth/authorize,POST 丢掉查询串后 Bangumi 返回 app_nonexistence,网页控制台账号登录永远失败。

真机(HK1,debug 包注入发版 client id/secret)验证:/start -> 验证码 -> 测试账号 -> success,tokenConfigured=true,7 天有效期。单测 5/5 绿;回退主代码则 2 个用例红。
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: adb02beb-101a-4508-86c0-08787c7e44cc
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@ModerRAS
ModerRAS merged commit f34dbf7 into master Nov 17, 2026
5 checks passed
@ModerRAS
ModerRAS deleted the fix/web-login-authorize-action branch November 17, 2026 04:00
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.

1 participant