{"record":{"id":"f740491a9097b850","repo":"mastra-ai/mastra","slug":"durable-agent-list-active-runs-invalid-page","errorCode":"DURABLE_AGENT_LIST_ACTIVE_RUNS_INVALID_PAGE","errorMessage":"DurableAgent \"${this.name}\" listActiveRuns() requires page to be a non-negative integer.","messagePattern":"DurableAgent \"(.+?)\" listActiveRuns\\(\\) requires page to be a non-negative integer\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/durable/durable-agent.ts","lineNumber":2912,"sourceCode":"   * for (const run of runs) {\n   *   await durableAgent.recoverActiveRuns({ runId: run.runId });\n   * }\n   * ```\n   */\n  async listActiveRuns(options: DurableAgentListActiveRunsOptions = {}): Promise<DurableAgentListActiveRunsResult> {\n    const { threadId, resourceId, fromDate, toDate, perPage, page } = options;\n\n    if (perPage !== undefined && (!Number.isInteger(perPage) || perPage <= 0)) {\n      throw new MastraError({\n        id: 'DURABLE_AGENT_LIST_ACTIVE_RUNS_INVALID_PER_PAGE',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.USER,\n        text: `DurableAgent \"${this.name}\" listActiveRuns() requires perPage to be a positive integer.`,\n        details: { agentName: this.name, perPage },\n      });\n    }\n    if (page !== undefined && (!Number.isInteger(page) || page < 0)) {\n      throw new MastraError({\n        id: 'DURABLE_AGENT_LIST_ACTIVE_RUNS_INVALID_PAGE',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.USER,\n        text: `DurableAgent \"${this.name}\" listActiveRuns() requires page to be a non-negative integer.`,\n        details: { agentName: this.name, page },\n      });\n    }\n\n    const workflowsStore = await this.#mastra?.getStorage()?.getStore('workflows');\n\n    if (!workflowsStore) {\n      throw new MastraError({\n        id: 'DURABLE_AGENT_LIST_ACTIVE_RUNS_NO_STORAGE',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.USER,\n        text:\n          `DurableAgent \"${this.name}\" listActiveRuns() requires storage to discover running runs. ` +\n          `Register the agent on a Mastra instance with persistent storage (e.g. PostgreSQL, LibSQL). See https://mastra.ai/docs/storage`,","sourceCodeStart":2894,"sourceCodeEnd":2930,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/durable/durable-agent.ts#L2894-L2930","documentation":"DurableAgent.listActiveRuns() validates pagination arguments before querying storage. The `page` parameter, when provided, must be a non-negative integer (0-based page index). A negative number, NaN, or a non-integer like 1.5 triggers this MastraError with ErrorCategory.USER.","triggerScenarios":"Calling listActiveRuns({ page }) where page is negative (e.g. -1), a float (e.g. 1.5), or otherwise not an integer (e.g. NaN from parsed input). Only raised when page !== undefined.","commonSituations":"Computing page indexes with off-by-one subtraction (page-1 on page 0), parsing user query params with parseFloat, or passing undefined-derived NaN values from spreadsheet/CLI tooling.","solutions":["Pass a non-negative integer for page (0 is valid, the first page).","Omit `page` entirely if you only want the default first page.","Sanitize values derived from user input: Number.isInteger(page) && page >= 0 before calling."],"exampleFix":"// before\nawait agent.listActiveRuns({ page: currentPage - 1 });\n// after\nconst page = Math.max(0, Math.floor(currentPage - 1));\nawait agent.listActiveRuns({ page });","handlingStrategy":"validation","validationCode":"function isValidPage(page: unknown): page is number {\n  return page === undefined || (Number.isInteger(page) && page >= 0);\n}\nif (!isValidPage(page)) throw new TypeError('page must be a non-negative integer');\nawait agent.listActiveRuns({ page, perPage });","typeGuard":"function isNonNegativeInt(v: unknown): v is number {\n  return typeof v === 'number' && Number.isInteger(v) && v >= 0;\n}","tryCatchPattern":null,"preventionTips":["Coerce pagination from user input with Math.max(0, Math.floor(Number(page)))","Omit `page` when you want the first page instead of passing 1-based or computed values","Wrap pagination params in a shared sanitize helper used by all list calls"],"tags":["pagination","validation","user-input"],"backgroundTag":"invalid-pagination-argument","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}