{"record":{"id":"b6be284bdb2b83f7","repo":"Leantime/leantime","slug":"length-must-be-a-positive-integer","errorCode":null,"errorMessage":"Length must be a positive integer","messagePattern":"Length must be a positive integer","errorType":"validation","errorClass":"RangeException","httpStatus":null,"severity":"error","filePath":"app/Domain/Api/Services/Api.php","lineNumber":366,"sourceCode":"     * This function uses type hints now (PHP 7+ only), but it was originally\n     * written for PHP 5 as well.\n     *\n     * For PHP 7, random_int is a PHP core function\n     * For PHP 5.x, depends on https://github.com/paragonie/random_compat\n     *\n     * @param  int  $length  How many characters do we want?\n     * @param  string  $keyspace  A string of all possible characters to select from\n     *\n     * @throws Exception\n     *\n     * @api\n     */\n    public function randomStr(\n        int $length = 64,\n        string $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'\n    ): string {\n        if ($length < 1) {\n            throw new RangeException('Length must be a positive integer');\n        }\n\n        $pieces = [];\n        $max = mb_strlen($keyspace, '8bit') - 1;\n        for ($i = 0; $i < $length; $i++) {\n            $pieces[] = $keyspace[random_int(0, $max)];\n        }\n\n        return implode('', $pieces);\n    }\n\n    /**\n     * @todo Remove this.\n     *\n     * @see ../Controllers/Tickets.php\n     *\n     * @api\n     */","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/Leantime/leantime/blob/9a9f49f1008f4782b30f6723c54228f4f992e636/app/Domain/Api/Services/Api.php#L348-L384","documentation":"Error \"Length must be a positive integer\" thrown in Leantime/leantime.","triggerScenarios":"Thrown at app/Domain/Api/Services/Api.php:366 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9a9f49f1008f4782b30f6723c54228f4f992e636","analyzedAt":"2026-08-21T02:37:38.966Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}