Skip to content

Eden Treaty skips path segments that match JavaScript reserved property names (e.g., index) #244

Description

@camiloaromero23

What version of Elysia is running?

  • Elysia version: 1.4.18 - Eden Treaty version: 1.4.6

What platform is your computer?

Darwin 25.2.0 arm64 arm

What steps can reproduce the bug?

When defining an Elysia route with a path segment named index and accessing it via Eden Treaty, the index segment is omitted from the final URL.

Reproduction:

Server-side (Elysia):

const app = new Elysia()
  .get("/search/index/:indexId/stocks", () => ({ data: [] }));

Client-side (Eden Treaty):

const api = treaty<typeof app>("http://localhost:3000");

await api.search.index({ indexId: "123" }).stocks.get();
// Expected: GET /search/index/123/stocks
// Actual:   GET /search/123/stocks


### What is the expected behavior?

The request should be sent to `/search/index/123/stocks`



### What do you see instead?

The request is sent to `/search/123/stocks`, completely omitting the index segment.


### Additional information


## Analysis

It appears Eden Treaty's path builder doesn't properly handle property names that conflict with JavaScript reserved names or built-in object properties. The word index likely conflicts with array/string methods or similar built-in properties, causing the proxy to not intercept it as a path segment.

## Workaround
As a workaround I renamed the path segment to something else (e.g., `/indexx/` instead of `/index/`).

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

_No response_

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingreviewrequest for reporter to verify the result

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions