{"record":{"id":"380e3bcede51c73b","repo":"louislam/uptime-kuma","slug":"the-maximum-number-of-days-is-365","errorCode":null,"errorMessage":"The maximum number of days is 365","messagePattern":"The maximum number of days is 365","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"server/uptime-calculator.js","lineNumber":571,"sourceCode":"        }\n        throw new Error(\"Invalid status\");\n    }\n\n    /**\n     * @param {number} num the number of data points which are expected to be returned\n     * @param {\"day\" | \"hour\" | \"minute\"} type the type of data which is expected to be returned\n     * @returns {UptimeDataResult} UptimeDataResult\n     * @throws {Error} The maximum number of minutes greater than 1440\n     */\n    getData(num, type = \"day\") {\n        if (type === \"hour\" && num > 24 * 30) {\n            throw new Error(\"The maximum number of hours is 720\");\n        }\n        if (type === \"minute\" && num > 24 * 60) {\n            throw new Error(\"The maximum number of minutes is 1440\");\n        }\n        if (type === \"day\" && num > 365) {\n            throw new Error(\"The maximum number of days is 365\");\n        }\n        // Get the current time period key based on the type\n        let key = this.getKey(this.getCurrentDate(), type);\n\n        let total = {\n            up: 0,\n            down: 0,\n        };\n\n        let totalPing = 0;\n        let endTimestamp;\n\n        // Get the earliest timestamp of the required period based on the type\n        switch (type) {\n            case \"day\":\n                endTimestamp = key - 86400 * (num - 1);\n                break;\n            case \"hour\":","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/uptime-calculator.js#L553-L589","documentation":"Thrown by UptimeCalculator.getData(num, type) when `type === \"day\" && num > 365`. Bounds daily-resolution data to one year. Notably, the weekly/monthly/yearly expansions in getDataByDuration delegate to day type (7*num, 30*num, 365*num), so large compound durations hit this gate too.","triggerScenarios":"Direct getData(num, \"day\") with num > 365; getDataByDuration(\"Nd\") with N > 365; getDataByDuration(\"2y\") → getData(365*2=730, \"day\") → throws; getDataByDuration(\"13M\") → getData(30*13=390, \"day\") → throws; getDataByDuration(\"54w\") → getData(7*54=378, \"day\") → throws. The yearly badge (1y = 365) sits exactly at the limit and does not throw.","commonSituations":"Badge URL with multi-year duration (e.g. \"2y\") expecting it to work; status page configured with a long monthly window that compounds past 365 days; misunderstanding that weekly/monthly/yearly are converted to days internally and inherit the 365-day cap.","solutions":["Keep day-type ranges at or below 365; for multi-year display, aggregate manually or cap to 365.","Avoid compound durations that expand past 365 days: \"2y\", \"13M\", \"54w\" all throw.","If you need \"all history\", query the max supported window (\"1y\" / \"365d\") and document the cap.","Clamp the numeric portion before calling getData/ByDuration."],"exampleFix":"// before\nconst up = uptimeCalculator.getDataByDuration(\"2y\"); // -> getData(730,\"day\") -> throws\n\n// after\nconst up = uptimeCalculator.getDataByDuration(\"1y\"); // 365 days, at the limit\n// or clamp:\nconst up = uptimeCalculator.getData(Math.min(num, 365), \"day\");","handlingStrategy":"validation","validationCode":"if (type === \"day\") num = Math.min(num, 365);","typeGuard":"const withinDayLimit = (n) => typeof n === \"number\" && n > 0 && n <= 365;","tryCatchPattern":"try { getData(n, \"day\"); } catch (e) { if (/maximum number of days/.test(e.message)) getData(365, \"day\"); else throw e; }","preventionTips":["Avoid compound durations that exceed 365 days (2y, 13M, 54w).","Clamp the numeric portion of day-type requests.","Document that 1y sits exactly at the limit."],"tags":["uptime-calculator","limits","badge","validation","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}