Leantime/leantime · error · RangeException

Length must be a positive integer

Error message

Length must be a positive integer

What it means

Error "Length must be a positive integer" thrown in Leantime/leantime.

Source

Thrown at app/Domain/Api/Services/Api.php:366

     * This function uses type hints now (PHP 7+ only), but it was originally
     * written for PHP 5 as well.
     *
     * For PHP 7, random_int is a PHP core function
     * For PHP 5.x, depends on https://github.com/paragonie/random_compat
     *
     * @param  int  $length  How many characters do we want?
     * @param  string  $keyspace  A string of all possible characters to select from
     *
     * @throws Exception
     *
     * @api
     */
    public function randomStr(
        int $length = 64,
        string $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
    ): string {
        if ($length < 1) {
            throw new RangeException('Length must be a positive integer');
        }

        $pieces = [];
        $max = mb_strlen($keyspace, '8bit') - 1;
        for ($i = 0; $i < $length; $i++) {
            $pieces[] = $keyspace[random_int(0, $max)];
        }

        return implode('', $pieces);
    }

    /**
     * @todo Remove this.
     *
     * @see ../Controllers/Tickets.php
     *
     * @api
     */

View on GitHub (pinned to 9a9f49f100)

When it happens

Trigger: Thrown at app/Domain/Api/Services/Api.php:366 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Leantime/leantime@9a9f49f100 (2026-08-21). Data as JSON: /api/errors/b6be284bdb2b83f7. Report an issue: GitHub.