Incorrect number of parameters for endpoint

I have added Hilla to an existing project primarily used as an API for others to use.

I created a service:

@BrowserCallable
class DbService(
    val itemDao: DbItemDao,
) {
    @AnonymousAllowed
        fun getFullItem(id: String): Item {
        return itemDao.findById(UUID.fromString(id)).get()
    }
}

My generated endpoint looks like this:

async function getFullItem_1(id: string | undefined, init?: EndpointRequestInit_1): Promise<Item_1 | undefined> { return client_1.call("DbService", "getFullItem", { id }, init); }

I create this in my view to fetch my item (hardcoded UUID just for testing)

import {DbService} from 'Frontend/generated/endpoints';

export default function MainView() {
    useEffect(() => {
        DbService.getFullItem("7089ba52-9e16-49a1-bb9c-58143ab0d580").then(console.log);
    }, []);
    return(/* stuff */)
}

But my browser reports the following error in the console:
Uncaught (in promise) Error: Incorrect number of parameters for endpoint 'DbService' method 'getFullItem', expected: 1, got: 0

What am i doing wrong here?

At least the error message names a different service class (TextDbAmmoService) than your example.

Typo, my bad. Post is edited
I can also add that if i add a method that takes no arguments, like findAll(), i get no errors.

I cannot replicate the issue on 24.8.0 and 24.7.6. I used this code:

data class Item(val id: UUID, val name: String)

@Component
class DbItemDao {
    fun findById(id: UUID): Optional<Item> {
        // Return a dummy item for demonstration
        return Optional.of(Item(id, "Dummy Item"))
    }
}

@BrowserCallable
@AnonymousAllowed
class DbService constructor(itemDao: DbItemDao) {
    private val itemDao: DbItemDao = itemDao
    @AnonymousAllowed
    fun getFullItem(id: String): Item {
        return itemDao.findById(UUID.fromString(id)).get()
    }
}

and the exact TS effect you posted.

Which version of Vaadin are you using?

Checked my package.json and it was a mix between Vaadin 24.7.7 and 24.7.5 (created with npx @hilla/cli init --react.
Upgraded the packages to 24.8.0 by comparing to the skeleton starter. But the error still remains.

How does your POST request look? Where and how is the parameter sent? Because i cannot find it anywhere. No parameters, attributes or body.

The version mix is not a problem, as packages come from Hilla, Components, and other projects of Vaadin, which can have different minor versions. I have this for example:

    "@vaadin/bundles": "24.7.7",
    "@vaadin/hilla-file-router": "24.7.5",
    "@vaadin/hilla-frontend": "24.7.5",
    "@vaadin/hilla-lit-form": "24.7.5",
    "@vaadin/hilla-react-auth": "24.7.5",
    "@vaadin/hilla-react-crud": "24.7.5",
    "@vaadin/hilla-react-form": "24.7.5",
    "@vaadin/hilla-react-i18n": "24.7.5",
    "@vaadin/hilla-react-signals": "24.7.5",
    "@vaadin/polymer-legacy-adapter": "24.7.7",
    "@vaadin/react-components": "24.7.7",
    "@vaadin/vaadin-lumo-styles": "24.7.7",
    "@vaadin/vaadin-material-styles": "24.7.7",
    "@vaadin/vaadin-themable-mixin": "24.7.7",

These are the headers of my request:

POST /connect/DbService/getFullItem HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0
Accept: application/json
Accept-Language: en-GB,en;q=0.8,fr-FR;q=0.6,fr;q=0.4,it;q=0.2
Accept-Encoding: gzip, deflate, br, zstd
Content-Type: application/json
Content-Length: 45
Referer: http://localhost:8080/hilla
X-CSRF-Token: 577fc441-aefb-4f6e-a0ef-f8e7a0b193ba
Origin: http://localhost:8080
DNT: 1
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Connection: keep-alive
Cookie: JSESSIONID=A99690A484D3CD70646BF234BC0B86FB; csrfToken=577fc441-aefb-4f6e-a0ef-f8e7a0b193ba
Priority: u=4
Pragma: no-cache
Cache-Control: no-cache

And this is the response:

HTTP/1.1 200 
Content-Type: application/json;charset=UTF-8
Content-Length: 65
Date: Mon, 23 Jun 2025 13:28:07 GMT
Keep-Alive: timeout=60
Connection: keep-alive

{"id":"7089ba52-9e16-49a1-bb9c-58143ab0d580","name":"Dummy Item"}

Thank you. If i manually edit my request and add the following in the (empty) body i can get the expected response. Any theory on what might be causing this?

{
    "id": "<uuid>"
}

You could try putting a breakpoint in your TS code to find out what steps it takes to form a request without that id.

This is embarrasing, it looks like the problem was our custom middleware (because the context-path is bugged, or not working as we expected, we had to do a rewrite of the request path).

For future reference, this was our middleware:

const mwareFunction = async (context: MiddlewareContext, next: MiddlewareNext) => {
    if (["GET", "POST"].includes(context.request.method) && (context.request.url.includes("/ammo/connect/"))) {
        const newUrl = context.request.url.replace("/ammo", "")
        context.request = new Request(
            newUrl, context.request
        );
    }
    return next(context);
}

const client_1 = new ConnectClient_1({prefix: "connect", middlewares: [mwareFunction]});
export default client_1;

This is our working middleware, problem was that the Request constructor does not clone the body by default:

const mwareFunction = async (context: MiddlewareContext, next: MiddlewareNext) => {
    if (["GET", "POST"].includes(context.request.method) && (context.request.url.includes("/ammo/connect/"))) {
        const newUrl = context.request.url.replace("/ammo", "")

        const body = context.request.method === 'POST'
            ? await context.request.clone().json()
            : undefined;

        context.request = new Request(newUrl, {
            method: context.request.method,
            headers: context.request.headers,
            body: body,
            credentials: context.request.credentials,
            cache: context.request.cache,
            redirect: context.request.redirect,
            referrer: context.request.referrer,
            referrerPolicy: context.request.referrerPolicy,
            mode: context.request.mode,
        });
    }
    return next(context);
}