Skip to content

Incorrect query validation error fields #1660

@daopk

Description

@daopk

What version of Elysia is running?

[email protected]

What platform is your computer?

Darwin 25.2.0 arm64 arm

What environment are you using

Bun 1.3.5

Are you using dynamic mode?

No

What steps can reproduce the bug?

  1. Run the following code:
import { Elysia, t } from "elysia";

const app = new Elysia()
  .get("/", ({ query }) => query, {
    query: t.Object({
      limit: t.Number({ minimum: 1, maximum: 100, default: 10 }),
    }),
  })
  .listen(3000);
  1. Visit: http://localhost:3000?limit=200

What is the expected behavior?

The response should return a validation error containing something like:

{
  "type": "validation",
  "on": "query",
  "property": "/limit",
// ...
}

What do you see instead?

The error response contains unexpected values for the on and property fields, for example:

{
  "type": "validation",
  "on": "property",
  "property": "root",
// ...
}

Additional information

When accessing
http://localhost:3000?limit=string
the validation error returns the correct on and property fields.

{
  "type": "validation",
  "on": "query",
  "property": "/limit",
  "message": "Expected union value",
// ...
}

Have you try removing the node_modules and bun.lockb and try again yet?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions