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
test(runtime): typed file-route tests never send the file name #474
The runtime file routes end in a wildcard segment: PUT|GET /runtime/files/:patchId/:versionId/:store/* and GET /runtime/shared-files/:patchId/:versionId/:alias/*. Effect's HttpApiClient fills only :name parameters (compilePath matches /(\/?):(\w+)(\?)?/g), so tests that call these routes through the typed client send a literal /* instead of the file name.
One consequence: in packages/runtime/src/RuntimeEvents.test.ts, the check that wide events never contain "private-filename" cannot fail, because that name never reaches the server.
Fix: build these requests with the real URL, as RuntimeApi.test.ts now does for headers the typed client drops, then confirm the assertions still hold. Found while typechecking the tests in the DX checks PR.
Category: bug Summary: Runtime tests that call the file routes through the typed client should send the real file name, so the filename-privacy assertion can fail.
Current behavior: RuntimeGroup's putFile, getFile and getSharedFile paths end in a * wildcard segment. Effect 4.0.0's HttpApiClient (compilePath) only fills in :name segments, so the client sends a literal *, and the server's router passes * to the handler as the file name. Verified during triage: in the runtime wide-events test "records PUT and GET bytes and their early refusals without retaining filenames or bodies", the files.put and files.get handlers receive { store: "private-store", name: "*" }, never "private-filename". Its assertion that no wide event contains "private-filename" therefore cannot fail.
The same applies to the runtime HTTP admission tests that use api.getFile / api.putFile, including the UndeclaredHeadersApi endpoint defined for the Origin test. Their expected outcomes don't depend on the name: they're refused before the name matters, or the default fixture has no file handler and returns invalid_request. They still don't send the request they describe.
Only tests are affected. Production builds these URLs by hand: the shell broker and the CLI's client transport both join [patchId, versionId, store|alias, ...name.split("/")], each segment URI-encoded.
Desired behavior:
Every runtime-package test that calls a wildcard file route sends the real URL: path segments filled in and URI-encoded, and the name split on / with each part encoded. The wide-events test proves the real name reached the handler before asserting that the name never appears in an event.
The Files HTTP suite in @patchy/primitives already does this with a small fileUrl helper derived from RuntimeGroup.endpoints.getFile.path. Follow that pattern. The runtime package's test fixtures module is the natural home for an equivalent helper. Note that the issue body's pointer to "as RuntimeApi.test.ts now does" is misleading: its UndeclaredHeadersApi still goes through the typed client and has the same problem.
Key interfaces:
RuntimeGroup.endpoints.getFile.path / putFile.path: the source for the URL template, so the helper follows route changes
The runtime test fixtures' client (HttpApiTest.groups(...)): file-route calls move off its putFile/getFile methods onto requests that carry the real URL, keeping the same headers, payload and response-only assertions
The files.put / files.get test handlers in the wide-events test: they should assert the name they receive
Acceptance criteria:
In the wide-events filename test, the files.put and files.get handlers assert they received name: "private-filename" (and store: "private-store"). The test fails if the URL regresses to a literal *.
That test's existing assertions all still hold: statuses, event outcomes, limits, five events, and no "private-store" / "private-filename" in any recorded event.
No runtime-package test calls a wildcard file route through the typed client's generated methods. A grep for api.putFile( / api.getFile( in the runtime tests comes back empty, or every remaining call builds its own URL.
The runtime HTTP admission tests that hit file routes, including the multi-segment folder/photo.png read and the PUT Origin test, send the real encoded name and keep their current expected statuses and codes.
pnpm check passes.
Out of scope:
Product code: the route definitions, RuntimeApi handlers, the shell broker and the CLI transport are correct
Patching or working around Effect's HttpApiClient wildcard handling
Adding new getSharedFile HTTP coverage (nothing calls it through the typed client today)
Sharing one URL helper across packages; a per-package test helper is fine
Activity
chore(dev): faster checks agents can trust, and a pnpm dev that needs…
allisonmahmood commentedon Oct 2, 2026
Agent Brief
Category: bug
Summary: Runtime tests that call the file routes through the typed client should send the real file name, so the filename-privacy assertion can fail.
Current behavior:
RuntimeGroup'sputFile,getFileandgetSharedFilepaths end in a*wildcard segment. Effect 4.0.0'sHttpApiClient(compilePath) only fills in:namesegments, so the client sends a literal*, and the server's router passes*to the handler as the file name. Verified during triage: in the runtime wide-events test "records PUT and GET bytes and their early refusals without retaining filenames or bodies", thefiles.putandfiles.gethandlers receive{ store: "private-store", name: "*" }, never"private-filename". Its assertion that no wide event contains"private-filename"therefore cannot fail.The same applies to the runtime HTTP admission tests that use
api.getFile/api.putFile, including theUndeclaredHeadersApiendpoint defined for the Origin test. Their expected outcomes don't depend on the name: they're refused before the name matters, or the default fixture has no file handler and returnsinvalid_request. They still don't send the request they describe.Only tests are affected. Production builds these URLs by hand: the shell broker and the CLI's client transport both join
[patchId, versionId, store|alias, ...name.split("/")], each segment URI-encoded.Desired behavior:
Every runtime-package test that calls a wildcard file route sends the real URL: path segments filled in and URI-encoded, and the name split on
/with each part encoded. The wide-events test proves the real name reached the handler before asserting that the name never appears in an event.The Files HTTP suite in
@patchy/primitivesalready does this with a smallfileUrlhelper derived fromRuntimeGroup.endpoints.getFile.path. Follow that pattern. The runtime package's test fixtures module is the natural home for an equivalent helper. Note that the issue body's pointer to "as RuntimeApi.test.ts now does" is misleading: itsUndeclaredHeadersApistill goes through the typed client and has the same problem.Key interfaces:
RuntimeGroup.endpoints.getFile.path/putFile.path: the source for the URL template, so the helper follows route changesclient(HttpApiTest.groups(...)): file-route calls move off itsputFile/getFilemethods onto requests that carry the real URL, keeping the same headers, payload and response-only assertionsfiles.put/files.gettest handlers in the wide-events test: they should assert thenamethey receiveAcceptance criteria:
files.putandfiles.gethandlers assert they receivedname: "private-filename"(andstore: "private-store"). The test fails if the URL regresses to a literal*."private-store"/"private-filename"in any recorded event.api.putFile(/api.getFile(in the runtime tests comes back empty, or every remaining call builds its own URL.folder/photo.pngread and the PUT Origin test, send the real encoded name and keep their current expected statuses and codes.pnpm checkpasses.Out of scope:
RuntimeApihandlers, the shell broker and the CLI transport are correctHttpApiClientwildcard handlinggetSharedFileHTTP coverage (nothing calls it through the typed client today)fix(test): runtime file-route tests send the real file name