Skip to content

Key request.body by HTTP method (#845, #861) - #870

Merged
jimhoyd merged 1 commit into
mainfrom
claude/per-method-body
Sep 28, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/per-method-body

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Covers #845's acceptance point that GET and POST on one declared path must be expressible and reviewable, and #861 item 5. Also closes #842: the "declare one route per method" advice is removed from review, TOOLING and SPECIFICATION.

Shape

/api/requests:
  methods: [GET, POST]
  request:
    body:
      GET: {maxBytes: 0}
      POST: {required: true, format: json, contentTypes: [application/json], schema: {...}}
  • This is the only way to write a body rule; the route-wide shape is removed with no alias. It gives one place per rule and matches OpenAPI's per-operation request body. The reasoning is in docs/HTTP.md under "Per-method body rules".
  • A key must be one of the route's methods. A method with no entry keeps the server limit.
  • GET, HEAD and DELETE entries may only set maxBytes (RFC 9110); maxBytes: 0 refuses a body with 413. POST, PUT, PATCH and OPTIONS take the full policy.
  • Runtime: body reads are sized per method on Node, AWS and Vercel. The router compiles one validator per method.
  • Cloudflare: one standalone validator per method, and a Worker with any method's validator missing refuses to start.
  • Tooling: explain, the manifest, the report, get_schema, get_capability, the MCP authoring context, feature plans, readiness and fixture suggestions all show per-method rules.
  • Fixture runner fix: it now sends Content-Length, so GET-with-body cases reach the route instead of failing with 400.

Evidence (macOS, Node 26), rebased on main with #865

Limits

  • The generated YAML reference repeats the schema-profile text under each full-policy method.
  • The workerd parity run cannot send a GET with a body, so that 413 is covered only by the Node-run Worker test.

Closes #842

🤖 Generated with Claude Code

`request.body` now maps each of a route's declared methods to its own
policy, so one path can take no body on GET and a required, schema-checked
JSON body on POST. This matches OpenAPI, where each operation on a path has
its own request body. It is the only way to write a body rule, including on
a single-method route, and there is no alias for the old route-wide shape.

- A key outside the route's `methods` fails at load. A method without an
  entry has no body policy.
- GET, HEAD and DELETE entries may only set `maxBytes`, because RFC 9110
  gives their content no defined meaning. `maxBytes: 0` refuses a body with
  413.
- Node, AWS and Vercel size the body read from the request method's
  policy (`requestLimit(target, method)`), and `checkRequest` applies only
  that method's policy.
- The Cloudflare build writes one standalone validator per route and
  method. The artifact maps each method to its validator, and the Worker
  refuses to start when any method's validator is missing.
- `explain`, `manifest`, the report, `get_schema`/`get_capability`, the
  authoring context, feature plans, readiness advisories and fixture
  suggestions all show the per-method shape.
- review no longer gives #842's "declare one route per method" advice
  (`method-dispatch`). Branching on `request.method` is the specified shape
  for several methods on one path. SPECIFICATION.md no longer suggests
  splitting a path either.
- The fixture runner now frames a case's body with Content-Length, so a
  GET body can be tested.
- examples/body-validation adds a GET+POST `/requests` route. Every
  example, recipe, fixture and doc now uses the new shape.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 28, 2026 22:13
@jimhoyd
jimhoyd merged commit 655b205 into main Sep 28, 2026
30 checks passed
@jimhoyd
jimhoyd deleted the claude/per-method-body branch September 28, 2026 22:18
jimhoyd added a commit that referenced this pull request Oct 1, 2026
…ion hint, shared env/secrets (#1131, #1132, #1133) (#1134)

* fix(core): upgrade leaves a recorded site; add reports a record-only change (#1131)

The reported failure came from a 0.6.5 `urlcode upgrade` moving a site to
0.6.6: that release's upgrade wrote no addon-files.lock.json at all, so the
0.6.6 `extensions list --strict` found every add-on unrecorded. The current
upgrade already records moved add-ons inside its rollback, but an up-to-date
site returned early, so re-running upgrade could never repair that state.

- upgrade on an up-to-date site records each installed catalog add-on that
  still matches the installed core's pin and has no entry; a package npm moved
  off its pin is left for list --strict to report. UpgradeResult gains
  `recorded`, printed by the CLI.
- writeFilesLock writes a temporary file and renames it into place, and a
  failed write is a ConfigError naming the file, so a record is never torn.
- extensions|artifacts add reports `recorded` and says "Recorded the installed
  files of <name>" instead of "nothing to do" when only the record changed.
- Tests: upgrade then list --strict passes with tarball-installed add-ons; an
  up-to-date unrecorded site is repaired; a mispinned one is not recorded; a
  record that cannot be written fails upgrade and rolls everything back; add
  reports the record write and "nothing to do" only for a true no-op.
- docs/EXTENSIONS.md, CLI help and llms-full.txt describe it.

Refs #1131

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(core): targeted migration hint for the route-wide request.body shape (#1132)

Policy keys (required, maxBytes, contentTypes, format, schema) written
directly under request.body in a route or a shared block, the shape #870
keyed by HTTP method, now fail with one legacy-request-body error before the
schema runs, instead of a generic unknown-key error for the first one only.

- The error is located at the first such place (file:line:column, pointer,
  key) and gives one instruction per route and shared block, each later one
  with its own line and column: the keys to move, the method keys to move
  them under, and a one-line before/after (key names only, never values).
- A route with methods moves every key under each method that takes a body,
  and maxBytes alone under its GET/HEAD/DELETE. A route without methods
  answers GET and HEAD: maxBytes moves under both, and any other key gets
  the suggestion to declare methods: [POST]. A shared block uses the methods
  every route that uses it answers.
- explainError (MCP explain_error) returns the error's own hint as its
  guidance, so the CLI, MCP validate and explain_error give the same text.
- docs/HTTP.md gains "Moving from the route-wide body shape" with the
  before/after, which the hint links through docsUrl(). No alias and no
  rewriting.

Refs #1132

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(config): shared blocks may carry env and secrets (#1133)

Owner decision 2026-10-01 reverses the declined #576. A top-level shared
block may declare env and secrets with the route-level shapes. A route that
names it with use inherits them, merged name by name; the route's own entry
wins. use is a single name, so two blocks can never conflict.

Bindings are resolved into each route at load time, before hashing, so
projectSha256, urlcode permissions (requested grants per route), the
operator policy's per-route grants and revision pin, explain and audit all
see each route's effective bindings. A block grants nothing and nothing
becomes project-wide; adding a route to a block changes its requested
grants and the revision, so the old pin is refused.

Adds examples/shared-bindings, schema $defs envBindings/secretBindings
shared by routes and shared blocks, tests, and docs (specification,
bindings guide, FUNCTION-SECURITY, SECURITY, RIM-CFG-002).

Refs #1133, #576

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(package): core size budget from the merged #1131-#1133 measurement

Measured on the merged branch (Node 26): 1120281 packed, 4396305 unpacked,
565 entries. Budgets: 1098 KiB packed, 4300 KiB unpacked, 570 entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(check): agent-facts counts only packages/ directories that hold source

The #1121 workspace-package fact listed every directory under packages/, so an
older checkout keeping a removed package's untracked dist/ or node_modules/
(ui, admin, forms, ...) failed check:docs and agent-facts.test.ts. A directory
now counts only when it holds a package.json or core's src/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

[Bug]: Authoring review recommends unsupported per-method route split for one path

1 participant