You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Gap]: middleware recipe and cookbook keep constant-response functions that respond expresses #599
functions/status.mjs (/negotiated, behind negotiate.mjs) is also a fixed answer but is not flagged (its body contains the word state, which the conservative detector treats as dynamic).
The same three functions exist in examples/cookbook/functions/ for the same routes in examples/cookbook/routes/middleware.yaml, and test/recipes.test.ts requires the recipe and cookbook modules to stay identical.
These routes are trusted, and on a trusted route the middleware can read a respond body. I replaced the three function: handlers in recipes/middleware/urlcode.yaml with equivalent respond: {json: …} values as a trial: urlcode test --project recipes/middleware passed 64 of 64 fixtures (envelope, ETag/304 and negotiation included). I reverted the trial to keep #555 in scope.
docs/MIDDLEWARE-EXAMPLES.md ("Native bodies stay opaque") says envelope, negotiate and etag rewrite a body only when the downstream response is a function response. That matches sandbox: true routes, not the trusted routes these modules run on. The guest-API framing on the same page is tracked in #558.
Code or YAML you had to write by hand
The three function modules above, which respond expresses.
Suggested change
Replace the three functions with respond in both the recipe and the cookbook, delete the modules, regenerate examples/cookbook/route-index.json, and reword the "Native bodies stay opaque" bullet so it applies only to sandbox: true routes. Check that the constant-response review signal then reports nothing for the recipe.
Verification
Verified: the trial conversion passed the recipe's fixtures. Not verified: the cookbook fixtures with the same conversion.
Activity