Describe the Bug
In @mastra/client-js, client.listLogs and client.getLogForRun drop the page and perPage query parameters when their value is 0, because they guard with a truthy check instead of an undefined check:
// client.ts (listLogs ~625, getLogForRun ~673)
if (page) {
searchParams.set('page', String(page));
}
if (perPage) {
searchParams.set('perPage', String(perPage));
}
page and perPage are typed as optional number. if (page) is falsy for 0, so page: 0 (the first page) and perPage: 0 are never sent, and the server falls back to its own defaults, returning the wrong page.
Every other paginated method in the same client guards with !== undefined (for example listMemoryThreads, getMcpServers, listScoresByRunId, and the resources under resources/). These two log methods are the only sites using a truthy check.
Steps To Reproduce
client.listLogs({ transportId: 't', page: 0, perPage: 0 })
// request URL: /api/logs?transportId=t (page and perPage are missing)
Expected Behavior
page=0 and perPage=0 are included in the query string, matching every other paginated method.
Actual Behavior
page and perPage are omitted whenever they are 0.
Additional Context
Fix is to change the four guards to !== undefined. I have a PR ready with unit tests.
Describe the Bug
In
@mastra/client-js,client.listLogsandclient.getLogForRundrop thepageandperPagequery parameters when their value is0, because they guard with a truthy check instead of anundefinedcheck:pageandperPageare typed as optionalnumber.if (page)is falsy for0, sopage: 0(the first page) andperPage: 0are never sent, and the server falls back to its own defaults, returning the wrong page.Every other paginated method in the same client guards with
!== undefined(for examplelistMemoryThreads,getMcpServers,listScoresByRunId, and the resources underresources/). These two log methods are the only sites using a truthy check.Steps To Reproduce
Expected Behavior
page=0andperPage=0are included in the query string, matching every other paginated method.Actual Behavior
pageandperPageare omitted whenever they are0.Additional Context
Fix is to change the four guards to
!== undefined. I have a PR ready with unit tests.