Thanks to visit codestin.com
Credit goes to github.com

Skip to content

API error if you use Quantity as configurable option #34

@HayKer97

Description

@HayKer97

If you use as configurable option type "Quantity", the Variable will be interpreted as integer while the environment array always need strings.
In my example, the wrong Value is at MAX_PLAYERS

This problem only appears if you up- or downgrade a server in whmcs.

Module Log:
Request:

{
    "environment":
    {
        "HHGS":"mcv",
        "BUILD_VANILLA_VERSION":"latest",
        "BUILD_PURGE":"false",
        "BUILD_CREATE_BACKUP_ON_SAME_SERVER":"false",
        "BUILD_PURGE_AFTER_BACKUP_ON_SAME_SERVER":"false",
        "MAX_PLAYERS":6,
        "MOTD":"Bla",
        "GAMEMODE":"0",
        "DIFFICULTY":"2",
        "PVP":"true",
        "FLIGHT":"false",
        "NETHER":"true",
        "SPAWNMOBS":"true",
        "SPAWNNPC":"true",
        "SPAWNANIMALS":"true",
        "SPAWNSTRUCTURES":"true"
    },
    "startup":"\/tmp\/.run",
    "egg":25,
    "image":"bla",
    "skip_scripts":false
}

Response:

Array
(
    [errors] => Array
        (
            [0] => Array
                (
                    [code] => DataValidationException
                    [status] => 500
                    [detail] => Could not save Pterodactyl\Models\ServerVariable[739]: failed to validate data: {"variable_value":["The variable value must be a string."]}
                )

        )

    [status_code] => 500
)

If I use the Dropdown type for configurable options, it will work.
The MAX_PLAYER value is a string here.

Request:

{
    "environment":
    {
        "HHGS":"mcv",
        "BUILD_VANILLA_VERSION":"latest",
        "BUILD_PURGE":"false",
        "BUILD_CREATE_BACKUP_ON_SAME_SERVER":"false",
        "BUILD_PURGE_AFTER_BACKUP_ON_SAME_SERVER":"false",
        "MAX_PLAYERS":"8",
        "MOTD":"Bla",
        "GAMEMODE":"0",
        "DIFFICULTY":"2",
        "PVP":"true",
        "FLIGHT":"false",
        "NETHER":"true",
        "SPAWNMOBS":"true",
        "SPAWNNPC":"true",
        "SPAWNANIMALS":"true",
        "SPAWNSTRUCTURES":"true"
    },
    "startup":"\/tmp\/.run",
    "egg":25,
    "image":"Bla",
    "skip_scripts":false
}

Response:

[...]
    [status_code] => 200
)

I remember this worked in the past with the Quantity type also.
So I would fix it by my self, but my PHP knowledge is too small :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions