Repository navigation
Commit afba96e
fix(runtime): an addressed /automation/:ns/:name/(runs|trigger) under an unserved verb answers the automation domain, as its bare path does (#33926)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCpddLFmKzR39wJWZpkRMCi)_
Fixes #33026
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:独立服务器上,带命名空间地址的
`/automation/:ns/:name/runs`、`/automation/:ns/:name/trigger`、`/automation/trigger/:ns/:name`
收到不支持的方法时,改由自动化领域回答(与不带地址的同一路由一致),不再由传输层回答。
- 为什么改:同一路由因写法不同返回两种错误信封、两种 `Allow`;匿名调用者在带地址写法上拿到 405(暴露路由形状)而不是 401。
- 风险与回滚:只在调度器里多声明三条「领域决定所有方法」的路由;已服务的方法照旧;回滚即还原该 PR。
- 先看:`packages/runtime/src/dispatcher-plugin.ts`
新增的三行声明;`automation-every-verb.hono.integration.test.ts` 的新行与命名空间假数据。
- 两分钟验证:`pnpm --filter @objectstack/runtime exec vitest run
src/automation-every-verb.hono.integration.test.ts`,预期 57/57 通过。
- 需要你做的:无,席位落地。
## What changes
- `registerAutomationRoutes`
(`packages/runtime/src/dispatcher-plugin.ts`) declares three more
patterns through `domainDecidesEveryVerb` (#24228's mechanism): GET
`/automation/:ns/:name/runs`, POST `/automation/:ns/:name/trigger`, POST
`/automation/trigger/:ns/:name`. These are the addressed shapes
(ADR-0150 D5) of the bare rows that were already declared. A verb the
router cannot route on them now reaches `dispatch()`, so the anonymous
floor answers `401` and the domain's `automationRouteAllow` answers
`405` with `Allow: GET` / `Allow: POST` in the dispatcher's envelope.
- Measured before the change, on a real Hono socket at `1e65a389`:
`DELETE /api/v1/automation/crm/send_digest/runs` answered `405`, `Allow:
GET, HEAD`, with an `error.details` envelope, for a signed-in and an
anonymous caller alike. The bare `DELETE
/api/v1/automation/send_digest/runs` answered the domain's `405 Allow:
GET` (signed in) and `401` (anonymous). The domain itself was never at
fault: dispatched directly, the addressed shapes already answer its
`405` (`automation-addressed-route.test.ts`). The gap was only the
transport declaration. No edit to `runtime/src/domains/automation.ts`.
## Tests
`automation-every-verb.hono.integration.test.ts` (both prefixes):
- Added rows: DELETE / POST / PUT on `/automation/crm/send_digest/runs`,
GET on `/automation/crm/send_digest/trigger` and GET on
`/automation/trigger/crm/send_digest`. Each row has an anonymous `401`
case and a signed-in domain `405` case.
- Added controls: a served POST on both addressed triggers runs the
flow; GET and DELETE on `/automation/no_such_ns/send_digest/runs` answer
the dispatcher's `404 ROUTE_NOT_FOUND`.
- `crm` is installed through an ObjectQL registry double answering the
holder table the address reads.
<details><summary>Ablation, one per declaration
(scripts/ablation-replace.mjs, each restored to the HEAD blob with git
diff HEAD empty)</summary>
- Without `:ns/:name/runs`: `Tests 14 failed | 43 passed (57)`. The
failures are every addressed `/runs` row on both prefixes, plus the
no-namespace DELETE control.
- Without `:ns/:name/trigger`: `Tests 4 failed | 53 passed (57)`. The
failures are the anonymous and signed-in GET on
`/automation/crm/send_digest/trigger`, on both prefixes.
- Without `trigger/:ns/:name`: `Tests 4 failed | 53 passed (57)`. The
failures are the anonymous and signed-in GET on
`/automation/trigger/crm/send_digest`, on both prefixes.
</details>
## Acceptance notes
- Same behaviour on a `createHonoApp` host (catch-all): it already
handed every verb to `dispatch()`. No change there.
## Verification
Readings at `9bdd492b`, the head before the last `origin/main` merge.
That merge brought no change to the three files here.
- `pnpm --filter @objectstack/runtime typecheck`: exit 0.
- `pnpm --filter @objectstack/runtime test`: `Test Files 603 passed
(603) / Tests 10934 passed | 19 skipped`.
- Direct dependents exercising the dispatcher on Hono:
`@objectstack/http-conformance` test, `Test Files 20 passed / Tests 292
passed`. `@objectstack/client` `package-addressing.test.ts`, `83
passed`.
- `automation-every-verb.hono.integration.test.ts`: `57 passed (57)`.
- eslint on both touched `.ts` files: exit 0.
- `dispatch-gates --commands`: 67 run, reconciled with `--ran` (67
derived, 67 run). 65 exit 0. Two NOT MEASURED on prerequisites:
`check:dual-build-cjs-loads` needs a full `pnpm build`;
`check:type-check-debt`'s inner build never got the lock.
Final head `39826829` (merge of `origin/main`, which carries #33721 and
#33844 in `packages/runtime`): the scoped re-check (closure build,
runtime typecheck, the every-verb, addressed-route, contract-mounts,
clone-mount and route-ledger suites) is NOT MEASURED. The shared verify
lock was held by another worktree's run for over 27 minutes. CI's Test
Core runs the package on this head.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jUZKdq3PK2Sab53cT3)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent de3538c commit afba96e
3 files changed
Lines changed: 73 additions & 0 deletions
File tree
- .changeset
- packages/runtime/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
| |||
42 | 50 | | |
43 | 51 | | |
44 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
45 | 59 | | |
46 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
47 | 66 | | |
48 | 67 | | |
49 | 68 | | |
| |||
67 | 86 | | |
68 | 87 | | |
69 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
70 | 101 | | |
71 | 102 | | |
72 | 103 | | |
| |||
190 | 221 | | |
191 | 222 | | |
192 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
193 | 245 | | |
194 | 246 | | |
195 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2074 | 2074 | | |
2075 | 2075 | | |
2076 | 2076 | | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
2077 | 2086 | | |
2078 | 2087 | | |
2079 | 2088 | | |
| |||
0 commit comments