TypeError in InitiateBackupService.php #251

Closed
opened 2026-02-05 17:20:18 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @masterjanic on GitHub (Feb 2, 2025).

Current Behavior

When hitting the rate limit defined in the app config and trying to create another backup, a type error status 500 will be thrown instead of the correct rate limit error. (API)

  errors: [
    {
      code: 'TypeError',
      status: '500',
      detail: 'An unexpected error was encountered while processing this request, please try again.'
    }
  ]

Origin seems to be

431c1977e3/app/Services/Backups/InitiateBackupService.php (L87)

Expected Behavior

Endpoint should throw the correct error.

Steps to Reproduce

Check defined rate limit for backup creation like

    'throttles' => [
        'limit' => env('BACKUP_THROTTLE_LIMIT', 2),
        'period' => env('BACKUP_THROTTLE_PERIOD', 600),
    ],

Create more backups than allowed. See Laravel logs and response message.

Panel Version

1.0.0-beta17

Wings Version

1.0.0-beta9

Games and/or Eggs Affected

No response

Docker Image

No response

Error Logs

https://paste.pelistuff.com/7AQs

Is there an existing issue for this?

  • I have searched the existing issues before opening this issue.
  • I have provided all relevant details, including the specific game and Docker images I am using if this issue is related to running a server.
  • I have checked in the Discord server and believe this is a bug with the software, and not a configuration issue with my specific system.
Originally created by @masterjanic on GitHub (Feb 2, 2025). ### Current Behavior When hitting the rate limit defined in the app config and trying to create another backup, a type error status 500 will be thrown instead of the correct rate limit error. (API) ```js errors: [ { code: 'TypeError', status: '500', detail: 'An unexpected error was encountered while processing this request, please try again.' } ] ``` Origin seems to be https://github.com/pelican-dev/panel/blob/431c1977e3a858bcd816e7e4b3113fd27ddf26af/app/Services/Backups/InitiateBackupService.php#L87 ### Expected Behavior Endpoint should throw the correct error. ### Steps to Reproduce Check defined rate limit for backup creation like ```php 'throttles' => [ 'limit' => env('BACKUP_THROTTLE_LIMIT', 2), 'period' => env('BACKUP_THROTTLE_PERIOD', 600), ], ``` Create more backups than allowed. See Laravel logs and response message. ### Panel Version 1.0.0-beta17 ### Wings Version 1.0.0-beta9 ### Games and/or Eggs Affected _No response_ ### Docker Image _No response_ ### Error Logs https://paste.pelistuff.com/7AQs ### Is there an existing issue for this? - [x] I have searched the existing issues before opening this issue. - [x] I have provided all relevant details, including the specific game and Docker images I am using if this issue is related to running a server. - [x] I have checked in the Discord server and believe this is a bug with the software, and not a configuration issue with my specific system.
Author
Owner

@Lochnair commented on GitHub (Mar 19, 2025):

Just ran into something similar using the panel, when going past the default limit of 2 backups, I get:

Image

Log excerpt
[2025-03-19 05:44:29] production.ERROR: Carbon\CarbonImmutable::rawAddUnit(): Argument #3 ($value) must be of type int|float, string given, called in /var/www/html/vendor/nesbot/carbon/src/Carbon/Traits/Units.php on line 356 {"userId":1,"exception":"[object] (TypeError(code: 0): Carbon\\CarbonImmutable::rawAddUnit(): Argument #3 ($value) must be of type int|float, string given, called in /var/www/html/vendor/nesbot/carbon/src/Carbon/Traits/Units.php on line 356 at /var/www/html/vendor/nesbot/carbon/src/Carbon/Traits/Units.php:455)
[stacktrace]
#0 /var/www/html/vendor/nesbot/carbon/src/Carbon/Traits/Units.php(356): Carbon\\CarbonImmutable::rawAddUnit(Object(Carbon\\CarbonImmutable), 'second', '600')
#1 /var/www/html/vendor/nesbot/carbon/src/Carbon/Traits/Date.php(2903): Carbon\\CarbonImmutable->addUnit('second', '600', NULL)
#2 /var/www/html/vendor/nesbot/carbon/src/Carbon/Traits/Date.php(2594): Carbon\\CarbonImmutable->callModifierMethod('second', Array)
#3 /var/www/html/app/Services/Backups/InitiateBackupService.php(88): Carbon\\CarbonImmutable->__call('addSeconds', Array)
#4 /var/www/html/app/Filament/Server/Resources/BackupResource/Pages/ListBackups.php(169): App\\Services\\Backups\\InitiateBackupService->handle(Object(App\\Models\\Server), 'test2')
#5 /var/www/html/vendor/filament/support/src/Concerns/EvaluatesClosures.php(35): App\\Filament\\Server\\Resources\\BackupResource\\Pages\\ListBackups->App\\Filament\\Server\\Resources\\BackupResource\\Pages\\{closure}(Object(App\\Services\\Backups\\InitiateBackupService), Array)

I tested wrapping getting the period from the config with intval:

public function handle(Server $server, ?string $name = null, bool $override = false): Backup
    {
        $limit = config('backups.throttles.limit');
        $period = intval(config('backups.throttles.period'));

Then when triggering the limit again, I instead get a 429 in the panel:

Image

Too bad is doesn't show the message from the exception, but still a lot clearer what's going on with a 429

@Lochnair commented on GitHub (Mar 19, 2025): Just ran into something similar using the panel, when going past the default limit of 2 backups, I get: ![Image](https://github.com/user-attachments/assets/5cf04759-2452-405d-b9e0-4f1ee6db86ac) <details> <summary>Log excerpt</summary> ``` [2025-03-19 05:44:29] production.ERROR: Carbon\CarbonImmutable::rawAddUnit(): Argument #3 ($value) must be of type int|float, string given, called in /var/www/html/vendor/nesbot/carbon/src/Carbon/Traits/Units.php on line 356 {"userId":1,"exception":"[object] (TypeError(code: 0): Carbon\\CarbonImmutable::rawAddUnit(): Argument #3 ($value) must be of type int|float, string given, called in /var/www/html/vendor/nesbot/carbon/src/Carbon/Traits/Units.php on line 356 at /var/www/html/vendor/nesbot/carbon/src/Carbon/Traits/Units.php:455) [stacktrace] #0 /var/www/html/vendor/nesbot/carbon/src/Carbon/Traits/Units.php(356): Carbon\\CarbonImmutable::rawAddUnit(Object(Carbon\\CarbonImmutable), 'second', '600') #1 /var/www/html/vendor/nesbot/carbon/src/Carbon/Traits/Date.php(2903): Carbon\\CarbonImmutable->addUnit('second', '600', NULL) #2 /var/www/html/vendor/nesbot/carbon/src/Carbon/Traits/Date.php(2594): Carbon\\CarbonImmutable->callModifierMethod('second', Array) #3 /var/www/html/app/Services/Backups/InitiateBackupService.php(88): Carbon\\CarbonImmutable->__call('addSeconds', Array) #4 /var/www/html/app/Filament/Server/Resources/BackupResource/Pages/ListBackups.php(169): App\\Services\\Backups\\InitiateBackupService->handle(Object(App\\Models\\Server), 'test2') #5 /var/www/html/vendor/filament/support/src/Concerns/EvaluatesClosures.php(35): App\\Filament\\Server\\Resources\\BackupResource\\Pages\\ListBackups->App\\Filament\\Server\\Resources\\BackupResource\\Pages\\{closure}(Object(App\\Services\\Backups\\InitiateBackupService), Array) ``` </details> I tested wrapping getting the period from the config with intval: ```php public function handle(Server $server, ?string $name = null, bool $override = false): Backup { $limit = config('backups.throttles.limit'); $period = intval(config('backups.throttles.period')); ``` Then when triggering the limit again, I instead get a 429 in the panel: ![Image](https://github.com/user-attachments/assets/55399e2b-16f6-41ad-bbba-b7af0fe9b7e5) Too bad is doesn't show the message from the exception, but still a lot clearer what's going on with a 429
Author
Owner

@rmartinoscar commented on GitHub (Mar 20, 2025):

Completed in https://github.com/pelican-dev/panel/pull/1132

@rmartinoscar commented on GitHub (Mar 20, 2025): Completed in https://github.com/pelican-dev/panel/pull/1132
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/panel-pelican-dev#251