exactMirror fails for wildcard route params schema containing "*" key — warn printed on every request
Author: 2286721642Created Sep 7, 2026Updated Sep 9, 2026
Labelsbug
What version of Elysia is running?
elysia: 1.4.29 (also present in 1.4.30)
What platform is your computer?
Linux 6.1.0-23-amd64 x86_64 unknown
What environment are you using
bun: 1.4.0
Are you using dynamic mode?
no
What steps can reproduce the bug?
import { Elysia, t } from 'elysia';
const app = new Elysia().get(
'/uploads/:type/*',
({ params }) => ({ ok: true, type: params.type, p: params['*'] }),
{
params: t.Object({
type: t.String(),
'*': t.String(),
}),
},
);
app.listen(3000);Then hit GET /uploads/images/2024-11-08/a.jpg — the warning above is printed for every request, while the response is still 200 {"ok":true,...}.
A route without an explicit params schema (e.g. app.get('/', ...)) does not trigger the warning, which confirms the trigger is the explicit object schema with an "" property.
What is the expected behavior?
No response
What do you see instead?
Failed to create exactMirror. Please report the following code to https://github.com/elysiajs/elysia/issues
log: {
[Symbol(TypeBox.Kind)]: "Object",
type: "object",
required: [ "type", "*" ],
properties: {
type: { [Symbol(TypeBox.Kind)]: "String", type: "string" },
"*": { [Symbol(TypeBox.Kind)]: "String", type: "string" },
},
additionalProperties: false,
}Additional information
Root cause analysis
- Elysia defaults to
normalize: true, and when an object schema hasadditionalProperties: falseit builds a fast decode function viaexact-mirror(validator.Clean):node_modules/elysia/dist/schema.js(~line 455):if (normalize && schema.additionalProperties === false)→validator.Clean = createMirror(schema, { TypeCompiler, ... }), wrapped in try/catch that falls back tocreateCleanerand prints the warning.
[email protected]'sisSpecialPropertycheck only tests for a blacklist of characters:const isSpecialProperty = (name) => /(\ |-|\t|\n|\.|\[|\]|\{|\})/.test(name) || !isNaN(+name[0]);"*"is not in that list andisNaN(+"*")istrue, so"*"is treated as a plain identifier. Property access is then emitted asv.*and object literal keys as{*: ...}— invalid JavaScript — andnew Function(...)throws aSyntaxError.- Elysia catches it, logs the warning, and falls back to
createCleaner. Because the mirror was never cached, the same failed attempt + warning repeats on every request.
Fix status / why bumping Elysia does not help
[email protected]already fixed this by switchingisSpecialPropertyto a whitelist:const isSpecialProperty = (name) => !/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);- However elysia 1.4.30 still depends on
"exact-mirror": "^0.2.7", and exact-mirror 1.2.x requirestypebox >= 1.1.0as a peer dependency while elysia 1.4.x requires@sinclair/typebox < 1— so a project cannot upgrade exact-mirror to the fixed version without breaking typebox compatibility.
Suggested fixes (any of)
- Elysia: bump the dependency to
exact-mirror@^1.2.x(and align typebox accordingly), or - Elysia: special-case property names emitted by exact-mirror (avoid object schemas that contain wildcard-style keys such as
"*"from entering the mirror path), or - exact-mirror: backport the whitelist
isSpecialPropertyfix to a0.2.xrelease so^0.2.7resolvers pick it up.
Have you try removing the node_modules and bun.lock and try again yet?
No response
Source: elysiajs/elysia