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

[错误报告] rule_name 缺失导致 qBittorrent 无法删除规则 #280

Closed
ZhangTianrong opened this issue Jun 2, 2023 · 14 comments · Fixed by #282
Closed

[错误报告] rule_name 缺失导致 qBittorrent 无法删除规则 #280

ZhangTianrong opened this issue Jun 2, 2023 · 14 comments · Fixed by #282
Labels
bug Something isn't working

Comments

@ZhangTianrong
Copy link
Contributor

当前程序版本

DEV_VERSION b5c3be1

问题类型

WebUI

问题描述

使用 WebUI 添加番剧订阅后修改或删除订阅遇到因 rule_name 缺失导致的 qbittorrentapi.exceptions.MissingRequiredParameters400Error,直到下一次 rss_loop 运行时问题才得到解决。在运行 set_rule 获得 rule_name 前,订阅的记录就添加入了数据库,建议修改 src\module\manager\collector.py#L30 处的顺序,先 add_rss_feedset_rule, 最后 db.insert

发生问题时系统日志

[2023-06-02 01:26:00] DEBUG:    Authed.
[2023-06-02 01:26:00] ERROR     Exception in ASGI application
Traceback (most recent call last):
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 428, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\uvicorn\middleware\message_logger.py", line 86, in __call__
    raise exc from None
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\uvicorn\middleware\message_logger.py", line 82, in __call__
    await self.app(scope, inner_receive, inner_send)
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\fastapi\applications.py", line 276, in __call__
    await super().__call__(scope, receive, send)
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\starlette\applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\starlette\middleware\errors.py", line 184, in __call__
    raise exc
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\starlette\middleware\errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
    raise exc
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in __call__
    raise e
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\starlette\routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\starlette\routing.py", line 276, in handle
    await self.app(scope, receive, send)
    self._client.rss_remove_rule(rule_name)
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\qbittorrentapi\decorators.py", line 91, in wrapper
    return func(client, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\qbittorrentapi\rss.py", line 313, in rss_remove_rule
    self._post(_name=APINames.RSS, _method="removeRule", data=data, **kwargs)
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\qbittorrentapi\request.py", line 390, in _post
    return self._request_manager(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\qbittorrentapi\request.py", line 465, in _request_manager
    return self._request(
           ^^^^^^^^^^^^^^
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\qbittorrentapi\request.py", line 542, in _request
    self._handle_error_responses(data, params, response)
  File "c:\Users\<username>\Tools\Auto_Bangumi\env\Lib\site-packages\qbittorrentapi\request.py", line 752, in _handle_error_responses
    raise MissingRequiredParameters400Error()
qbittorrentapi.exceptions.MissingRequiredParameters400Error
@ZhangTianrong ZhangTianrong added the bug Something isn't working label Jun 2, 2023
@EstrellaXD
Copy link
Owner

请附上 config.json 里面的 Downloader 部分,可以不用用户名和密码,在看下 QB 中自动下载规则里面的路径一栏

@ZhangTianrong
Copy link
Contributor Author

"downloader": {
        "type": "qbittorrent",
        "host": "127.0.0.1:5657",
        "username": "<username>",
        "password": "<password>",
        "path": "E:/Downloads/AutoBangumi",
        "ssl": false
    }

@EstrellaXD
Copy link
Owner

既然你是本地运行的,可以在 /src/module/downloader/path.py L54 打一个断点,看下运行结果。手上没有 windows 环境没办法我这边测试。确实没碰到过 Windows 本地 + Windows 的情况

@ZhangTianrong
Copy link
Contributor Author

ZhangTianrong commented Jun 2, 2023

这和 Windows 没关系…… 关于 Windows 的那个 issue 我还没提呢。这是关于没有 rule_name 的问题,在 rss_loop 运行后(比如重启服务)会将 rule_name 更新,但此前所有从数据库获取的有关新订阅的 data 都缺失 rule_name 一项。至于 save_path, 在当前测试订阅中无问题,返回值正常,/src/module/downloader/path.py#L48 报错的问题和这里无关。

@EstrellaXD
Copy link
Owner

这和 Windows 没关系…… 关于 Windows 的那个 issue 我还没提呢。这是关于没有 rule_name 的问题,在 rss_loop 运行后(比如重启服务)会将 rule_name 更新,但此前所有从数据库获取的有关新订阅的 data 都缺失 rule_name 一项。

没有 rule_name 就是因为 Windows 下路径生成出问题了啊。我已经强调过一遍了,如果你认为你有更好的修复问题的方式请自行修复。

@ZhangTianrong
Copy link
Contributor Author

ZhangTianrong commented Jun 2, 2023

这和 Windows 没关系…… 关于 Windows 的那个 issue 我还没提呢。这是关于没有 rule_name 的问题,在 rss_loop 运行后(比如重启服务)会将 rule_name 更新,但此前所有从数据库获取的有关新订阅的 data 都缺失 rule_name 一项。

没有 rule_name 就是因为 Windows 下路径生成出问题了啊。我已经强调过一遍了,如果你认为你有更好的修复问题的方式请自行修复。

那为什么 rule_name 在第二次运行的时候就正常了呢?你不用看 _gen_save_path 的结果,直接看 _rule_name 岂不是更直观?_rule_name 返回为 因为太怕痛就全点防御力了。 S2.

数据库内容如下:
image

实测 Windows 的路径并无影响,qBittorrent 支持混用 \\/, 而问题实际在于新加入的条目没有 rule_namesave_path. 如果你坚持是 Windows 的 path convention 导致的问题,那么又怎么解释其他条目有 rule_name 呢?

@EstrellaXD
Copy link
Owner

这和 Windows 没关系…… 关于 Windows 的那个 issue 我还没提呢。这是关于没有 rule_name 的问题,在 rss_loop 运行后(比如重启服务)会将 rule_name 更新,但此前所有从数据库获取的有关新订阅的 data 都缺失 rule_name 一项。

没有 rule_name 就是因为 Windows 下路径生成出问题了啊。我已经强调过一遍了,如果你认为你有更好的修复问题的方式请自行修复。

那为什么 rule_name 在第二次运行的时候就正常了呢?你不用看 _gen_save_path 的结果,直接看 _rule_name 岂不是更直观?_rule_name 返回为 因为太怕痛就全点防御力了。 S2.

刚刚语气有点不好了,先道歉。从开始有点没搞清楚,你错误的数据是从旧版本数据迁移过来的,还是更新后新订阅的。缺少 save_path 是和 rule_name 是全体数据还是个别数据。

@ZhangTianrong
Copy link
Contributor Author

刚刚语气有点不好了,先道歉。从开始有点没搞清楚,你错误的数据是从 ** 旧版本 ** 数据迁移过来的,还是 ** 更新后 ** 新订阅的。缺少 save_path 是和 rule_name 是全体数据还是个别数据。

没事,毕竟在群里已经提到过很多问题,我想要确认问题的根源然后一个个当作 issue 提交而不是一股脑儿全塞进一个 issue, 但是在你的立场很容易认为它们都是同一个问题。

我提的所有问题都是在新的订阅上试验过的。比如上图中 22 与 23 行均为我升级到 3.0 后添加的,出现了 integrity 上的问题,即有的条目有 rule_name 而有的没有,这应该直接在 scheme 中就杜绝,设置该列为 notnone.

@EstrellaXD
Copy link
Owner

EstrellaXD commented Jun 2, 2023

已经定位到问题
是我阅读出问题了,再次致歉

@ZhangTianrong
Copy link
Contributor Author

你的添加是 RSS 解析器自动添加还是在 WebUI 手动点击 Subscribe。

手动点击 Subscribe 的。我想我在最开始就说明了是在 WebUI 中添加订阅的。我直到 MyBangumi 和其他订阅是不同的,毕竟对于 qBittorrent 来说 MyBangumi 只有一条 RSS, 我提 issue 前会确认是那种情况的。

EstrellaXD added a commit that referenced this issue Jun 2, 2023
@ZhangTianrong
Copy link
Contributor Author

已经定位到问题 是我阅读出问题了,再次致歉

行吧,那你直接改吧,我也不能完全确定我最开始给出的解决方案就是最好的。但是改发的牢骚我还是要发一下:我其实在尽我的能力让问题更加 specific 从而更容易修复,这其实能节约你的时间,但是可能是我在群里边 debug 边提出新 bug 的操作让你觉得不耐烦了,所以即便我有意在 issue 最开始就强调问题只出现在两次 rss_loop 之间而不是一直存在的,但你仍然会以 condescending 的 tone 认为这就是 Windows specific 的问题。

@ZhangTianrong
Copy link
Contributor Author

7fc349c 测试似乎问题未解决。

@EstrellaXD
Copy link
Owner

7fc349c 测试似乎问题未解决。

我这边测试没有出现问题,是否有没添加的 rule_name 等的 数据库 截图

@ZhangTianrong
Copy link
Contributor Author

确实修复了,之前在 main 分支,没有成功 checkout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants