mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 14:35:45 +00:00
`http`/`https` validate `options.method` with `checkIsHttpToken` before the request exists, so a
literal outside the RFC 9110 token class throws `ERR_INVALID_HTTP_TOKEN` and no request is
created. The analyzer reported one anyway.
Measured on Node 24.22.1:
| call | outcome |
| --- | --- |
| `http.request({method: "BAD METHOD"})` | THREW `ERR_INVALID_HTTP_TOKEN` |
| `http.request({method: "GET"})`, `{method: "POST"}` | request constructed |
| `http.request({method: ""})` | request constructed — empty is a valid token, Node falls back to GET |
| `http.request("http://h/", {method: "BAD METHOD"})` | THREW |
| `http.request(new URL("http://h/"), {method: "BAD METHOD"})` | THREW |
## What this decides, and what it deliberately does not
Only shapes where the copied value is certainly the syntactic one:
- slot 0 is an options literal, or
- slot 0 is a string, a template or a verified `new URL`, so the `(url, options)` overload is proven
Every other shape keeps the request. Each of these was measured and can put something else in the
slot or change the copied value:
| call | outcome | why undecided here |
| --- | --- | --- |
| `http.request(() => {}, {method: "BAD METHOD"})` | request constructed | slot 0 is the callback, slot 1 unread |
| `https.request(null, {method: "BAD METHOD"})` | request constructed | `https` keeps its default options for a falsy input |
| `{get x() { this.method = "GET"; }, method: "BAD METHOD"}` | request constructed | the getter runs before the copy |
| `{method: "BAD METHOD", get x() { this.method = "GET"; }}` | THREW | getter after the copy cannot rescue it, but this reader does not model copy order |
| `{...{host: "h"}, method: "BAD METHOD"}` | THREW | a spread may replace the member |
The last two are the honest gap in this change. Closing them needs `Object.assign`'s enumeration
order — integer keys first, first-insertion position for a redefined key — which is a different
piece of work and belongs in its own change rather than widening this one.
Keeping a request Node never makes is the safer direction, and it is the direction I chose
wherever the copy is not certainly the literal.
## Contract and boundary impact
- Semantic owner and earliest changed stage: request candidate collection in the JavaScript domain.
- CLI and MCP/tool-catalog contract: none.
- Provider, bridge, target-format, or platform compatibility: `fetch` and `WebSocket` keep their
existing behavior; both use a different member and do not validate a token.
- Evidence, artifact, provenance, or reconstruction contract: a refused call no longer reports a
request operation or its linked release.
- Generated metadata, package, or installation impact: none.
Expected effects:
- [x] Analysis facts only; no target interaction.
## Validation performed
- 15 cases in `javascriptSemanticAnalysis.http_method_token.test.ts`; reverting the reader fails 5.
- `src/domain/javascript` — 5644 passing.
- `npm run format:check` — exit 0.
- `npm run lint` — 0 errors.
## Before merge
- [x] This PR addresses a concrete problem or an agreed enhancement.
- [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
- [x] The PR has one focused outcome and the title follows `type(scope): outcome`.
- [x] Tests cover changed observable behavior and meaningful failure paths.
- [x] Owning docs, contracts, and generated metadata are updated where needed.
- [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
## Author readiness
Human owner: @XiaoBinGan
- [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
- [x] I checked the evidence above, confirm it supports the current change, and recorded meaningful validation gaps.
- [x] I declare this PR ready for initial maintainer review.