Skip to content

fix(config): 修复 parser_bili_video_codes 环境变量 Pydantic 校验失败问题 - #577

Closed
yuexps wants to merge 1 commit into
fllesser:masterfrom
yuexps:master
Closed

fix(config): 修复 parser_bili_video_codes 环境变量 Pydantic 校验失败问题#577
yuexps wants to merge 1 commit into
fllesser:masterfrom
yuexps:master

Conversation

@yuexps

@yuexps yuexps commented Jul 31, 2026

Copy link
Copy Markdown
  • 修复背景:在配置 parser_bili_video_codes 环境变量(如 ["hev", "av01", "avc"])时,因 bilibili_apiVideoCodecs 枚举成员值为元组类型,导致 Pydantic 默认枚举校验报 ValidationError。
image
  • 解决方案:在 Config 模型中增加 parser_bili_video_codes 的前置字段校验器(@field_validator(mode="before")),支持将字符串列表、JSON 数组及逗号分隔字符串自动转换并映射至对应的 VideoCodecs 枚举成员。
  • 影响范围:仅影响 config.pyparser_bili_video_codes 配置项的反序列化与兼容解析。
  • 测试验证:已验证测试修改后插件正常工作。

- 修复背景:在配置 parser_bili_video_codes 环境变量(如 ["hev", "av01", "avc"])时,因 bilibili_api 中 VideoCodecs 枚举成员值为元组类型,导致 Pydantic 默认枚举校验报 ValidationError。
- 解决方案:在 Config 模型中增加 parser_bili_video_codes 的前置字段校验器(@field_validator(mode="before")),支持将字符串列表、JSON 数组及逗号分隔字符串自动转换并映射至对应的 VideoCodecs 枚举成员。
- 影响范围:仅影响 config.py 中 parser_bili_video_codes 配置项的反序列化与兼容解析。
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
46 2 44 3
View the top 2 failed test(s) by shortest run time
tests.parsers.test_weibo::test_repost
Stack Traces | 1.01s run time
tests/parsers/test_weibo.py:60: in test_repost
    await asyncio.gather(*[parse_repost(url) for url in urls])
tests/parsers/test_weibo.py:46: in parse_repost
    parse_result = await parser.parse(keyword, searched)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../nonebot_plugin_parser/parsers/base.py:89: in parse
    return await self._handlers[keyword](self, searched)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../parsers/weibo/__init__.py:50: in _parse_m_weibo_cn
    return await self.parse_weibo_id(wid)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../parsers/weibo/__init__.py:193: in parse_weibo_id
    weibo_data = common.decoder.decode(response.content).data
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   msgspec.ValidationError: Object missing required field `data`
tests.parsers.test_nga::test_nga_parse
Stack Traces | 2.39s run time
tests/parsers/test_nga.py:21: in test_nga_parse
    result = await parser.parse(keyword, searched)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../nonebot_plugin_parser/parsers/base.py:89: in parse
    return await self._handlers[keyword](self, searched)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.../nonebot_plugin_parser/parsers/nga.py:73: in _parse
    raise ParseException(f"无法获取页面, HTTP {resp.status_code}")
E   nonebot_plugin_parser.exception.ParseException: 无法获取页面, HTTP 403

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@fllesser

Copy link
Copy Markdown
Owner

这个应该是 bilibili-api 中途改的,准备弃用 bilibili-api 了,vibe 好了没合,你先暂时用着吧

@yuexps

yuexps commented Jul 31, 2026

Copy link
Copy Markdown
Author

这个应该是 bilibili-api 中途改的,准备弃用 bilibili-api 了,vibe 好了没合,你先暂时用着吧

好的👌

@yuexps yuexps closed this Jul 31, 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