Internal Server Error upon Admin Login

Hii,

When I login into server using admin user, the shows “500 internal server error”.

Only the path “/list/user/” gives 500, rest other path like “/list/web/” works fine.

Below is the log of hestaicp nginx error log file


2025/06/08 14:12:00 [error] 1346812#0: *60 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught TypeError: ksort(): Argument #1 ($array) must be of type array, null given in /usr/local/hestia/web/list/user/index.php:27
Stack trace:
#0 /usr/local/hestia/web/list/user/index.php(27): ksort()
#1 {main}
  thrown in /usr/local/hestia/web/list/user/index.php on line 27" while reading response header from upstream, client: 122.160.123.197, server: _, request: "GET /list/user/ HTTP/2.0", upstream: "fastcgi://unix:/run/hestia-php.sock:", host: "server.ssoftwares.in:8083", referrer: "https://server.ssoftwares.in:8083/list/web/"

My Server Currently have 121 Users.

$data = json_decode(implode("", $output), true) ?? [];
if ($_SESSION["userSortOrder"] == "name") {
        ksort($data);
} else {
        $data = array_reverse($data, true);
}

after tinkering a little bit, I get to know the index.php file is calling command /usr/local/hestia/bin/v-list-users json > users.json to get user’s list and then parsing it in JSON, the command returns json but it is invalid which I confirmed after using a JSON parser online, that is why the $data is null and ksort function return exception because it was expecting an array. FYI: I added ?? ; to prevent exception.

But the root issue is that the json returned through v-list-users command is invalid. How did it happen and how can I correct it down?

After tinkering further, Going to line 6906 I find the above code and highlited error line.

My question is how did it occur in first place with that extra line? Also, How can I fix it now?

Reading the hestiacp v-list-users script, got to know that it reads user data from this file path /usr/local/hestia/data/users/$USER/user.conf , I went to the file and see the issue, there is a newline character in name,

Removing the newline character in user.conf file manually fixed the issue for me.

Root Cause: I think it happened because someone while adding user in my server pressed ‘Enter’ by mistake, or copied the name directly from somewhere which added newline character.

Such a small mistake could crash hestiacp panel. I would request the developers to validate the fields while user creating to prevent this.

Thanks

3 Likes

@surya, just here to say: nice debug work!

1 Like