Repository navigation
fix(middleware): declare withInjectionGuard's context parameter optional - #8644
Merged
diegosouzapw merged 1 commit intoJul 27, 2026
Conversation
This was referenced Jul 26, 2026
backryun
force-pushed
the
chore/ts7-types-batch-dispatch
branch
from
July 26, 2026 20:53
ec91078 to
fb34739
Compare
Collaborator
|
Hi @backryun — clean one-liner. Optional context removes the Approved as |
backryun
force-pushed
the
chore/ts7-types-batch-dispatch
branch
from
July 27, 2026 15:18
fb34739 to
a129b59
Compare
All five diagnostics in src/lib/batches/dispatch.ts are the same:
Type '(request: any, context: any) => Promise<any>' is not assignable to
type 'BatchRouteHandler'.
Target signature provides too few arguments. Expected 2 or more, but got 1.
`withInjectionGuard()` returns `guardedHandler(request, context: any)` with the
second parameter required, so every route it wraps advertises arity 2. The batch
dispatcher's `BatchRouteHandler` is `(request: Request) => …`, and TS rejects
assigning a function that needs an argument the caller will never supply.
The declaration was wrong about its own runtime. `dispatch.ts:48` already calls
`handler(request)` with one argument, and has been doing so in production;
`context` is only forwarded to the inner handler, where routes that do not read
it get `undefined`. Marking it `context?: any` states what was already true.
208 -> 203, zero new, on a line-number-agnostic diff of the full tsc error set.
One character; nothing executable changed.
No test added: the one-argument call path is the existing behaviour and is
already covered — embeddings-auth.test.ts and embeddings-route-apikeymeta-6929
call `POST(req)` directly through withInjectionGuard, which is exactly the arity
this now permits. 370/370 across the 43 injection-guard / batch / embeddings /
moderation suites; typecheck:core, eslint and check:file-size clean.
backryun
force-pushed
the
chore/ts7-types-batch-dispatch
branch
from
July 27, 2026 15:35
a129b59 to
f9810c7
Compare
diegosouzapw
merged commit Jul 27, 2026
6601ae3
into
cheaper-inference:release/v3.8.49
15 checks passed
Merged
HouMinXi
pushed a commit
to HouMinXi/OmniRoute
that referenced
this pull request
Aug 2, 2026
…nal (cheaper-inference#8644) All five diagnostics in src/lib/batches/dispatch.ts are the same: Type '(request: any, context: any) => Promise<any>' is not assignable to type 'BatchRouteHandler'. Target signature provides too few arguments. Expected 2 or more, but got 1. `withInjectionGuard()` returns `guardedHandler(request, context: any)` with the second parameter required, so every route it wraps advertises arity 2. The batch dispatcher's `BatchRouteHandler` is `(request: Request) => …`, and TS rejects assigning a function that needs an argument the caller will never supply. The declaration was wrong about its own runtime. `dispatch.ts:48` already calls `handler(request)` with one argument, and has been doing so in production; `context` is only forwarded to the inner handler, where routes that do not read it get `undefined`. Marking it `context?: any` states what was already true. 208 -> 203, zero new, on a line-number-agnostic diff of the full tsc error set. One character; nothing executable changed. No test added: the one-argument call path is the existing behaviour and is already covered — embeddings-auth.test.ts and embeddings-route-apikeymeta-6929 call `POST(req)` directly through withInjectionGuard, which is exactly the arity this now permits. 370/370 across the 43 injection-guard / batch / embeddings / moderation suites; typecheck:core, eslint and check:file-size clean. Co-authored-by: backryun <busan011@ormbiz.co.kr>
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…nal (cheaper-inference#8644) All five diagnostics in src/lib/batches/dispatch.ts are the same: Type '(request: any, context: any) => Promise<any>' is not assignable to type 'BatchRouteHandler'. Target signature provides too few arguments. Expected 2 or more, but got 1. `withInjectionGuard()` returns `guardedHandler(request, context: any)` with the second parameter required, so every route it wraps advertises arity 2. The batch dispatcher's `BatchRouteHandler` is `(request: Request) => …`, and TS rejects assigning a function that needs an argument the caller will never supply. The declaration was wrong about its own runtime. `dispatch.ts:48` already calls `handler(request)` with one argument, and has been doing so in production; `context` is only forwarded to the inner handler, where routes that do not read it get `undefined`. Marking it `context?: any` states what was already true. 208 -> 203, zero new, on a line-number-agnostic diff of the full tsc error set. One character; nothing executable changed. No test added: the one-argument call path is the existing behaviour and is already covered — embeddings-auth.test.ts and embeddings-route-apikeymeta-6929 call `POST(req)` directly through withInjectionGuard, which is exactly the arity this now permits. 370/370 across the 43 injection-guard / batch / embeddings / moderation suites; typecheck:core, eslint and check:file-size clean. Co-authored-by: backryun <busan011@ormbiz.co.kr>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #8484. One character. Clears all five diagnostics in
src/lib/batches/dispatch.ts.A declaration that was wrong about its own runtime
withInjectionGuard()returnswith the second parameter required, so every route it wraps advertises arity 2. The batch dispatcher's handler type is
(request: Request) => Promise<Response> | Response, and TS correctly refuses to assign a function that needs an argument the caller will never pass.The interesting part is which side was wrong.
dispatch.ts:48already calls it with one argument:and has been doing so in production.
contextis only forwarded on to the inner handler, where routes that do not read it receiveundefined— which is exactly what one-argument invocation produces. So the parameter has always been optional in practice; the signature just did not say so.Widening
BatchRouteHandlerto take two parameters would have been the other option, but that fixes it at the consumer and leaves four other wrapped routes still misdescribing their own arity.Verification
208 → 203, zero new errors, on a line-number-agnostic diff of the full
tscerror set.npm run typecheck:core— cleaneslint,check:file-size— cleanNothing executable changed — an optional marker has no runtime representation.
No test added — the path is the existing behaviour
Checking coverage of what the declaration now permits is standard for these slices, and here it is already thorough.
embeddings-auth.test.ts(4 call sites) andembeddings-route-apikeymeta-6929.test.tscallPOST(req)with a single argument straight throughwithInjectionGuard— precisely the arity this change legalises, exercised end-to-end and passing before and after.Worth noting what is not covered:
batch-processor.test.tsmocksdispatchBatchApiRequest, so the batch path never reaches a real guarded handler. That gap predates this change and is unaffected by it — the one-argument contract is proven by the route tests instead.