Skip to content

fix(loopback): 运行时事件区分未知字段与客户端错误 - #266

Open
Jone888999 wants to merge 2 commits into
NeverENG:mainfrom
Jone888999:fix/runtime-event-boundaries
Open

Jone888999 wants to merge 2 commits into
NeverENG:mainfrom
Jone888999:fix/runtime-event-boundaries

Conversation

@Jone888999

Copy link
Copy Markdown
Contributor

基于 #265。请先合并 #265;本 PR 目前显示 2 个提交,等 #265 合入 main 后会自动只剩「运行时事件」这一个提交。

Summary / 概述

/runtime/events 把未知字段当致命错误、把格式错误报成 500,并对 action_result 返回成功却什么都不记:宿主加字段就整条断,调用方错误被伪装成服务故障,动作审计承诺与实际记录不符。

Changes / 改动

  • runtime_ingress.py:accept_user 忽略未知字段并计数;record_delivery 类型校验前移,返回 400 invalid_runtime_reply;action_result 返回 501。
  • runtime.py:/status 暴露 runtime_ingress.ignored_fields。
  • server.py:非对象 JSON 返回 400 invalid_body(原为 500)。
  • 测试:未知字段计数、格式错误 400、action_result 501、/capture 数组 400。

Compatibility, data and privacy / 兼容性、数据与隐私

无存储/配置变更。action_result 由 200 改为 501 是线上可见变化,当前 DSH 无调用方;后续应同步 runtime-bridge.js 的 EVENTS 列表,或在客户端把 501 映射为 not_supported。错误体仍为 {"error": "<code>"},不含正文或令牌。

Risk and rollback / 风险与回滚

风险:ignored_fields 是以远端字段名为键的字典,异常宿主可让它增长(建议后续加上限)。回滚 git revert,无数据影响。

Checklist / 检查清单

  • I confirm the target branch is main
  • Code has passed local testing
  • I have added tests that prove my fix is effective
  • Docs are mirrored in docs/zh/ and docs/en/

验证:test_loopback_server_contract.py 10 OK(1 skipped)、test_loopback_runtime_ingress.py 9 OK、test_loopback_ingress.py 11 OK。

/healthz 的版本改读 metadata.yaml,返回 app_version/pid/ready/started_at,runtime_gate_enabled 读取本次启动的生效配置;正常退出(含 POSIX SIGTERM)删除本进程发布的 runtime.json,按端口与令牌核对,不删其它实例的文件。

不改变存储格式、公开配置与端点路径;Windows 不投递 SIGTERM 处理器,发现文件保留到下次启动覆盖。GitHub issue 编号待分配。
@Jone888999
Jone888999 force-pushed the fix/runtime-event-boundaries branch from ef918b4 to d4250ce Compare December 3, 2026 04:04
accept_user 忽略未知字段并计入 /status 的 runtime_ingress.ignored_fields,不再整条拒绝;record_delivery 字段类型错误返回 400 而非 500;action_result 在未接动作账本前明确返回 501;非对象 JSON 返回 400 invalid_body。

不改变存储格式、公开配置与端点路径。GitHub issue 编号待分配。
@Jone888999
Jone888999 force-pushed the fix/runtime-event-boundaries branch from d4250ce to a1d5499 Compare December 3, 2026 04:11

This branch has not been deployed

No deployments
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