Skip to content

fix: drop **kwargs bug in two register funcs#8141

Merged
Soulter merged 1 commit into
AstrBotDevs:masterfrom
lingyun14beta:fix/platform-adapter-type-permission-type-kwargs
May 15, 2026
Merged

fix: drop **kwargs bug in two register funcs#8141
Soulter merged 1 commit into
AstrBotDevs:masterfrom
lingyun14beta:fix/platform-adapter-type-permission-type-kwargs

Conversation

@lingyun14beta
Copy link
Copy Markdown
Contributor

@lingyun14beta lingyun14beta commented May 10, 2026

Fix #8140 ,register_platform_adapter_type 和 register_permission_type 调用 get_handler_or_create 时未透传 **kwargs,导致 priority 等参数被静默丢弃,handler 优先级不生效。

Modifications / 改动点

register_platform_adapter_type:调用 get_handler_or_create 时加上 **kwargs
register_permission_type:函数签名加入 **kwargs 并透传给 get_handler_or_create

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

使用脚本再次运行:
image


Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Ensure registration helpers correctly propagate configuration to created handlers.

Bug Fixes:

  • Fix platform adapter type registration so additional keyword options like priority are passed through when creating handlers.
  • Fix permission type registration to accept and forward keyword options to handler creation, preventing silent loss of configuration.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. area:core The bug / feature is about astrbot's core, backend labels May 10, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider accepting explicit keyword arguments (e.g., priority) in register_platform_adapter_type and register_permission_type instead of a generic **kwargs so that call sites get better IDE/static checking and it’s clearer which options are actually supported.
  • Since register_permission_type now takes **kwargs that are passed to get_handler_or_create, it might be helpful to guard against unexpected keys (e.g., by validating against get_handler_or_create’s signature) to avoid silently ignoring or misusing options.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider accepting explicit keyword arguments (e.g., `priority`) in `register_platform_adapter_type` and `register_permission_type` instead of a generic `**kwargs` so that call sites get better IDE/static checking and it’s clearer which options are actually supported.
- Since `register_permission_type` now takes `**kwargs` that are passed to `get_handler_or_create`, it might be helpful to guard against unexpected keys (e.g., by validating against `get_handler_or_create`’s signature) to avoid silently ignoring or misusing options.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@lingyun14beta
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the register_platform_adapter_type and register_permission_type functions in star_handler.py to accept and pass **kwargs to the get_handler_or_create call. This change enables more flexible handler metadata creation by allowing additional arguments to be passed through the decorators. I have no feedback to provide as there were no review comments.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies register_platform_adapter_type and register_permission_type in star_handler.py to support passing additional keyword arguments to get_handler_or_create. I have no feedback to provide.

@lingyun14beta
Copy link
Copy Markdown
Contributor Author

呃啊

@Soulter Soulter merged commit 094aef6 into AstrBotDevs:master May 15, 2026
20 of 21 checks passed
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core The bug / feature is about astrbot's core, backend lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] priority 不生效

2 participants