Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variables do not work properly #28

Closed
astrooom opened this issue Mar 3, 2021 · 11 comments
Closed

Environment variables do not work properly #28

astrooom opened this issue Mar 3, 2021 · 11 comments

Comments

@astrooom
Copy link

astrooom commented Mar 3, 2021

Latest Panel and Wings versions

The environment variables when creating/modifying servers through pydactyl either throws the exception:

env_with_defaults[var_name] = var['attributes'].get(
TypeError: 'int' object does not support item assignment

where 'int' is replaced by which type of data you give the variable (if i wrote "latest" it would be "str" etc).

or for some eggs, such as vanilla Minecraft - the exception:

raise PterodactylApiError('API Request resulted in errors: %s' %
dispydactyl.exceptions.PterodactylApiError: API Request resulted in errors: [{'code': 'ValidationException', 'status': '422', 'detail': 'The environment must be an array.', 'source': {'line': 130, 'file': '/vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php'}, 'meta': {'trace': ['#0 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Validation/ValidatesWhenResolvedTrait.php(26): Illuminate\Foundation\Http\FormRequest->failedValidation()', '#1 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FormRequestServiceProvider.php(30): Illuminate\Foundation\Http\FormRequest->validateResolved()', '#2 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Container/Container.php(1137): Illuminate\Foundation\Providers\FormRequestServiceProvider->Illuminate\Foundation\Providers\{closure}()', '#3 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Container/Container.php(1101): Illuminate\Container\Container->fireCallbackArray()', '#4 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Container/Container.php(1086): Illuminate\Container\Container->fireAfterResolvingCallbacks()', '#5 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Container/Container.php(707): Illuminate\Container\Container->fireResolvingCallbacks()', '#6 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\Container\Container->resolve()', '#7 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Container/Container.php(633): Illuminate\Foundation\Application->resolve()', '#8 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\Container\Container->make()', '#9 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Routing/RouteDependencyResolverTrait.php(79): Illuminate\Foundation\Application->make()', '#10 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Routing/RouteDependencyResolverTrait.php(48): Illuminate\Routing\ControllerDispatcher->transformDependency()', '#11 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Routing/RouteDependencyResolverTrait.php(28): Illuminate\Routing\ControllerDhp(196): Illuminate\Routing\Route->runController()', '#15 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Routing/Router.php(685): Illuminate\Routing\Route->run()', '#16 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Routing\Router->Illuminate\Routing\{closure}()', '#17 /var/www/pterodactyl/app/Http/Middleware/Api/AuthenticateIPAccess.php(28): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#18 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Pterodactyl\Http\Middleware\Api\AuthenticateIPAccess->handle()', '#19 /var/www/pterodactyl/app/Http/Middleware/Api/Application/AuthenticateApplicationUser.php(25): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#20 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Pterodactyl\Http\Middleware\Api\Application\AuthenticateApplicationUser->handle()', '#21 /var/www/pterodactyl/app/Http/Middleware/Api/AuthenticateKey.php(82): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#22 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Pterodactyl\Http\Middleware\Api\AuthenticateKey->handle()', '#23 /var/www/pterodactyl/app/Http/Middleware/Api/SetSessionDriver.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#24 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Pterodactyl\Http\Middleware\Api\SetSessionDriver->handle()', '#25 /var/www/pterodactyl/app/Http/Middleware/Api/ApiSubstituteBindings.php(75): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#26 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Pterodactyl\Http\Middleware\Api\ApiSubstituteBindings->handle()', '#27 /var/www/pterodactyl/app/Http/Middleware/Api/IsValidJson.php(36): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#28 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Pterodactyl\Http\Middleware\Api\IsValidJson->handle()', '#29 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#30 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Routing\Middleware\ThrottleRequests->handle()', '#31 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#32 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Routing/Router.php(687): Illuminate\Pipeline\Pipeline->then()', '#33 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\Routing\Router->runRouteWithinStack()', '#34 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Routing/Router.php(628): Illuminate\Routing\Router->runRoute()', '#35 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Routing/Router.php(617): Illuminate\Routing\Router->dispatchToRoute()', '#36 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(165): Illuminate\Routing\Router->dispatch()', '#37 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()', '#38 /var/www/pterodactyl/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#39 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\Proxy\TrustProxies->handle()', '#40 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#41 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()', '#42 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#43 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()', '#44 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#45 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle()', '#46 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#47 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\EncryptCookies->handle()', '#48 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#49 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle()', '#50 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()', '#51 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(140): Illuminate\Pipeline\Pipeline->then()', '#52 /var/www/pterodactyl/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(109): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()', '#53 /var/www/pterodactyl/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle()', '#54 {main}'], 'source_field': 'environment', 'rule': 'array'}}]

@iamkubi
Copy link
Owner

iamkubi commented Mar 3, 2021

Can you provide an example of what you're trying to do?

@astrooom
Copy link
Author

astrooom commented Mar 3, 2021

I am simply trying to create a server through pydactyl using the Environment option. For example, running this command:

client.servers.create_server(name='Pydactyl test', user_id=1, nest_id=8,
egg_id=76, memory_limit=0, swap_limit=0, backup_limit=0,
disk_limit=0, location_ids=[1], environment={"WORLD_NAME": "myworld"})

Where the egg is tModLoader for Terraria with the WORLD_NAME variable being the name for the world, results in:

env_with_defaults[var_name] = var['attributes'].get(
TypeError: 'str' object does not support item assignment

I've tried inputting all the environment variables for the egg in to the dictionary, as well as trying different ones, but I get the same error message.

The Minecraft Vanilla egg returns the long exception report above. There may be more eggs that return the same type of error as well, that I haven't tried.

@hwalker928
Copy link

Yep, I can confirm I am having the same issue with all of my eggs.

@iamkubi
Copy link
Owner

iamkubi commented Mar 4, 2021

I think there was an issue in 0.1.13 from some refactoring that was done for pagination. If you use 0.1.12 it should work.

I'll take a look and try to get that fixed.

@astrooom
Copy link
Author

astrooom commented Mar 4, 2021

0.1.12 doesn't work either because the backup_limit option has to be present.

EDIT:
Was able to fix the backup_limit option manually using hwalkers pull request, but the

env_with_defaults[var_name] = var['attributes'].get(
TypeError: 'str' object does not support item assignment

is still present when using environment

@hwalker928
Copy link

0.1.12 doesn't work either because the backup_limit option has to be present.

EDIT:
Was able to fix the backup_limit option manually using hwalkers pull request, but the

env_with_defaults[var_name] = var['attributes'].get(
TypeError: 'str' object does not support item assignment

is still present when using environment

The PR is now in master, just needs to be on PyPI.

@astrooom
Copy link
Author

astrooom commented Mar 4, 2021

PR for the environment- or for the backup_limit fix?

@hwalker928
Copy link

PR for the environment- or for the backup_limit fix?

For the backup_limit

@iamkubi iamkubi closed this as completed in 4ca044f Mar 5, 2021
@astrooom
Copy link
Author

astrooom commented Mar 5, 2021

Not sure why you closed it as the issue is still there :D. 0.1.12 didn't fix the environment variable.

@iamkubi
Copy link
Owner

iamkubi commented Mar 5, 2021

You can see the commit that closed the issue. It's fixed in 0.1.14.

@astrooom
Copy link
Author

astrooom commented Mar 5, 2021

I see, that's my bad. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants