Skip to content

[BUG] client-js listLogs/getLogForRun drop page and perPage when they are 0 #18631

Description

@abhay-codes07

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions