fix: 支持 Schema 2 card callback 中 operator.user_id 嵌套格式#505
Conversation
evandance
left a comment
There was a problem hiding this comment.
Thanks for finding this. Schema 2 card callbacks do have a different identity shape here, and the fallback direction is consistent with openclaw/openclaw#71670.
The PR is not ready as-is though: it fixes only the plugin interactive dispatch path. The same operator?.open_id callback identity read still exists in at least:
src/tools/ask-user-question.ts:221src/tools/auto-auth.ts:757
Both are card callback handlers reached before dispatchFeishuPluginInteractiveHandler(). Under the same Schema 2 payload shape, they will still lose the operator identity. For ask-user-question, that can bypass the intended "only the asked user may answer" check when senderOpenId is missing.
Could you sweep all card callback operator identity reads and apply the fix consistently, preferably through a small shared helper? Please also add a regression test with a Schema 2 payload where the operator identity is available through operator.user_id but operator.open_id is absent.
8988258 to
6715f8a
Compare
|
@evandance 感谢建议,之前确实没考虑周全。 src/core/card-action-operator.ts — 共享 helper 函数 resolveCardCallbackOperatorId(),优先取 open_id,回退到 user_id src/channel/interactive-dispatch.ts — 改用 helper(原有修复) |
evandance
left a comment
There was a problem hiding this comment.
Thanks for the thorough rework — the shared helper, all three sibling sites swept, and the eight test cases land exactly the asks from the prior review. The helper's location in src/core/ and the upstream-issue reference in the docstring are also right.
One adjustment before this is mergeable: the commit currently carries a Co-Authored-By: Claude Opus 4.7 <[email protected]> trailer. That doesn't match the repo's standard commit-message style — none of the recent merged commits, including AI-assisted contributions from other contributors, include Co-Authored-By trailers. Please amend the commit to drop the trailer and force-push.
Non-blocking nit: tests #6 and #8 document that {open_id: '', user_id: 'real'} returns ''. Since ask-user-question.ts:287's authorization check short-circuits on falsy senderOpenId, switching ?? to || in the helper would close that edge defensively. Up to you whether to fold that in now or as a follow-up.
6715f8a to
db44b77
Compare
Schema 2 的 card callback 中,operator identity 可能嵌套在 operator.user_id 下而非 operator.open_id(openclaw/openclaw#71670)。 提取共享 helper 函数 resolveCardCallbackOperatorId(),统一处理 所有 card callback handler 中的 operator identity 解析: - src/core/card-action-operator.ts — 共享 helper(新增) - src/channel/interactive-dispatch.ts — 使用 helper - src/tools/ask-user-question.ts — 使用 helper(修复安全隐患) - src/tools/auto-auth.ts — 使用 helper Fixes #71670
db44b77 to
526c211
Compare
evandance
left a comment
There was a problem hiding this comment.
Thanks for the thorough rework — the shared helper, all three sibling sites covered, the eight test cases, and the proactive ?? → || adoption all land cleanly. One detail isn't quite right but doesn't block this merge: test #6's title says "returns undefined" but the assertion is .toBe('') (the inline comment is correct, just the title). Approving.
问题
Schema 2 的 card callback 中,operator identity 可能嵌套在
operator.user_id下而非operator.open_id。当前代码只读取operator.open_id,导致 Schema 2 格式的 card button action 被静默丢弃。对应 OpenClaw issue: openclaw/openclaw#71670
修改内容
src/channel/interactive-dispatch.ts:FeishuCardActionTriggerEvent接口增加user_id可选字段extractBasics()中senderOpenId增加operator.user_id作为 fallback适配背景
此修改适配 OpenClaw v2026.5.10-beta.5 中的 Feishu 相关修复。