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

Upgrade Error - ValueError: str_repeat(): Argument #2 ($times) must be greater than or equal to 0 #29023

Closed
kinimodmeyer opened this issue Oct 1, 2021 · 18 comments · Fixed by #31877
Assignees
Labels
3. to review Waiting for reviews bug
Milestone

Comments

@kinimodmeyer
Copy link

kinimodmeyer commented Oct 1, 2021

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce

  1. try to upgrade from 22.1.1 to 22.2.1

Expected behaviour

System should not crash and be broken

Actual behaviour

2021-10-01T18:14:47+02:00 Updating <accessibility> ...
2021-10-01T18:14:47+02:00 Repair step: Migrate old user config
2021-10-01T18:14:47+02:00 Migrate old user config
2021-10-01T18:14:47+02:00 
2021-10-01T18:14:47+02:00  Starting ...
    0/0 [>-]   0%2021-10-01T18:14:47+02:00 
 Starting ...
   70/0 [->]   0%An unhandled exception has been thrown:
ValueError: str_repeat(): Argument #2 ($times) must be greater than or equal to 0 in /var/.../3rdparty/symfony/console/Helper/ProgressBar.php:497
Stack trace:
#0 /var/.../3rdparty/symfony/console/Helper/ProgressBar.php(497): str_repeat()
#1 /var/.../3rdparty/symfony/console/Helper/ProgressBar.php(568): Symfony\Component\Console\Helper\ProgressBar::Symfony\Component\Console\Helper\{closure}()
#2 [internal function]: Symfony\Component\Console\Helper\ProgressBar->Symfony\Component\Console\Helper\{closure}()
#3 /var/.../3rdparty/symfony/console/Helper/ProgressBar.php(581): preg_replace_callback()
#4 /var/.../3rdparty/symfony/console/Helper/ProgressBar.php(393): Symfony\Component\Console\Helper\ProgressBar->buildLine()
#5 /var/.../3rdparty/symfony/console/Helper/ProgressBar.php(352): Symfony\Component\Console\Helper\ProgressBar->display()
#6 /var/.../3rdparty/symfony/console/Helper/ProgressBar.php(312): Symfony\Component\Console\Helper\ProgressBar->setProgress()
#7 /var/.../core/Command/Upgrade.php(142): Symfony\Component\Console\Helper\ProgressBar->advance()
#8 /var/.../3rdparty/symfony/event-dispatcher/EventDispatcher.php(264): OC\Core\Command\Upgrade->OC\Core\Command\{closure}()
#9 /var/.../3rdparty/symfony/event-dispatcher/EventDispatcher.php(239): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch()
#10 /var/.../3rdparty/symfony/event-dispatcher/EventDispatcher.php(73): Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
#11 /var/.../lib/private/EventDispatcher/SymfonyAdapter.php(123): Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
#12 /var/.../lib/private/Repair.php(251): OC\EventDispatcher\SymfonyAdapter->dispatch()
#13 /var/.../lib/private/Repair.php(282): OC\Repair->emit()
#14 /var/.../apps/accessibility/lib/Migration/RepairUserConfig.php(85): OC\Repair->advance()
#15 /var/.../lib/private/User/Manager.php(646): OCA\Accessibility\Migration\RepairUserConfig->OCA\Accessibility\Migration\{closure}()
#16 /var/.../apps/accessibility/lib/Migration/RepairUserConfig.php(86): OC\User\Manager->callForSeenUsers()
#17 /var/.../lib/private/Repair.php(123): OCA\Accessibility\Migration\RepairUserConfig->run()
#18 /var/.../lib/private/legacy/OC_App.php(1059): OC\Repair->run()
#19 /var/.../lib/private/legacy/OC_App.php(996): OC_App::executeRepairSteps()
#20 /var/.../lib/private/Updater.php(345): OC_App::updateApp()
#21 /var/.../lib/private/Updater.php(262): OC\Updater->doAppUpgrade()
#22 /var/.../lib/private/Updater.php(130): OC\Updater->doUpgrade()
#23 /var/.../core/Command/Upgrade.php(241): OC\Updater->upgrade()
#24 /var/.../3rdparty/symfony/console/Command/Command.php(255): OC\Core\Command\Upgrade->execute()
#25 /var/.../3rdparty/symfony/console/Application.php(1009): Symfony\Component\Console\Command\Command->run()
#26 /var/.../3rdparty/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand()
#27 /var/.../3rdparty/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
#28 /var/.../lib/private/Console/Application.php(209): Symfony\Component\Console\Application->run()
#29 /var/.../console.php(99): OC\Console\Application->run()
#30 /var/.../occ(11): require_once('...')
#31 {main}
Keep maintenance mode active? [y/N] 

restart upgrade throws the exact same error.
if you make the upgrade step without the updater.phar it went through.

i had such a error on last upgrade too but on circles nextcloud/circles#807

@kinimodmeyer kinimodmeyer added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Oct 1, 2021
@solracsf solracsf changed the title 22.2.0 upgrade error - ValueError: str_repeat(): Argument #2 ($times) must be greater than or equal / Migrate old user config 22.2.0 Upgrade Error - ValueError: str_repeat(): Argument #2 ($times) must be greater than or equal to 0 Oct 1, 2021
@kesselb
Copy link
Contributor

kesselb commented Oct 1, 2021

Can you run find . | grep ProgressBar from the server folder?

@solracsf
Copy link
Member

solracsf commented Oct 1, 2021

I've got some logs on this too while upgrading from 21.0.5 to 22.2.0, but no crash 💥

{
  "reqId": "bnfPOQSgsQ7eZX1x2yq0",
  "level": 3,
  "time": "2021-10-02T01:20:05+02:00",
  "remoteAddr": "",
  "user": "--",
  "app": "PHP",
  "method": "",
  "url": "--",
  "message": "str_repeat(): Second argument has to be greater than or equal to 0 at /3rdparty/symfony/console/Helper/ProgressBar.php#497",
  "userAgent": "--",
  "version": "21.0.5.1",
  "exception": {
    "Exception": "Error",
    "Message": "str_repeat(): Second argument has to be greater than or equal to 0 at /3rdparty/symfony/console/Helper/ProgressBar.php#497",
    "Code": 0,
    "Trace": [
      {
        "function": "onError",
        "class": "OC\\Log\\ErrorHandler",
        "type": "::",
        "args": [
          2,
          "str_repeat(): Second argument has to be greater than or equal to 0",
          "/3rdparty/symfony/console/Helper/ProgressBar.php",
          497,
          {
            "bar": "*** sensitive parameter replaced ***",
            "output": "*** sensitive parameter replaced ***",
            "completeBars": 24,
            "display": "------------------------",
            "emptyBars": -23
          }
        ]
      },
      {
        "file": "/3rdparty/symfony/console/Helper/ProgressBar.php",
        "line": 497,
        "function": "str_repeat",
        "args": [
          "-",
          -23
        ]
      },
      {
        "file": "/3rdparty/symfony/console/Helper/ProgressBar.php",
        "line": 568,
        "function": "Symfony\\Component\\Console\\Helper\\{closure}",
        "class": "Symfony\\Component\\Console\\Helper\\ProgressBar",
        "type": "::",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "function": "Symfony\\Component\\Console\\Helper\\{closure}",
        "class": "Symfony\\Component\\Console\\Helper\\ProgressBar",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/3rdparty/symfony/console/Helper/ProgressBar.php",
        "line": 581,
        "function": "preg_replace_callback",
        "args": [
          "{%([a-z\\-_]+)(?:\\:([^%]+))?%}i",
          {
            "__class__": "Closure"
          },
          " %message%\n %current%/%max% [%bar%] %percent:3s%%"
        ]
      },
      {
        "file": "/3rdparty/symfony/console/Helper/ProgressBar.php",
        "line": 393,
        "function": "buildLine",
        "class": "Symfony\\Component\\Console\\Helper\\ProgressBar",
        "type": "->",
        "args": []
      },
      {
        "file": "/3rdparty/symfony/console/Helper/ProgressBar.php",
        "line": 352,
        "function": "display",
        "class": "Symfony\\Component\\Console\\Helper\\ProgressBar",
        "type": "->",
        "args": []
      },
      {
        "file": "/3rdparty/symfony/console/Helper/ProgressBar.php",
        "line": 312,
        "function": "setProgress",
        "class": "Symfony\\Component\\Console\\Helper\\ProgressBar",
        "type": "->",
        "args": [
          1
        ]
      },
      {
        "file": "/core/Command/Upgrade.php",
        "line": 142,
        "function": "advance",
        "class": "Symfony\\Component\\Console\\Helper\\ProgressBar",
        "type": "->",
        "args": [
          1
        ]
      },
      {
        "file": "/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
        "line": 264,
        "function": "OC\\Core\\Command\\{closure}",
        "class": "OC\\Core\\Command\\Upgrade",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
        "line": 239,
        "function": "doDispatch",
        "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          [
            {
              "__class__": "Closure"
            },
            {
              "__class__": "Closure"
            }
          ],
          "*** sensitive parameter replaced ***",
          "*** sensitive parameter replaced ***"
        ]
      },
      {
        "file": "/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
        "line": 73,
        "function": "callListeners",
        "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          [
            {
              "__class__": "Closure"
            },
            {
              "__class__": "Closure"
            }
          ],
          "*** sensitive parameter replaced ***",
          "*** sensitive parameter replaced ***"
        ]
      },
      {
        "file": "/lib/private/EventDispatcher/SymfonyAdapter.php",
        "line": 123,
        "function": "dispatch",
        "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          "*** sensitive parameter replaced ***",
          "*** sensitive parameter replaced ***"
        ]
      },
      {
        "file": "/lib/private/Repair.php",
        "line": 251,
        "function": "dispatch",
        "class": "OC\\EventDispatcher\\SymfonyAdapter",
        "type": "->",
        "args": [
          "*** sensitive parameter replaced ***",
          {
            "__class__": "Symfony\\Component\\EventDispatcher\\GenericEvent"
          }
        ]
      },
      {
        "file": "/lib/private/Repair.php",
        "line": 282,
        "function": "emit",
        "class": "OC\\Repair",
        "type": "->",
        "args": [
          "\\OC\\Repair",
          "advance",
          [
            1,
            ""
          ]
        ]
      },
      {
        "file": "/apps/accessibility/lib/Migration/RepairUserConfig.php",
        "line": 85,
        "function": "advance",
        "class": "OC\\Repair",
        "type": "->",
        "args": []
      },
      {
        "file": "/lib/private/User/Manager.php",
        "line": 646,
        "function": "OCA\\Accessibility\\Migration\\{closure}",
        "class": "OCA\\Accessibility\\Migration\\RepairUserConfig",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/apps/accessibility/lib/Migration/RepairUserConfig.php",
        "line": 86,
        "function": "callForSeenUsers",
        "class": "OC\\User\\Manager",
        "type": "->",
        "args": [
          {
            "__class__": "Closure"
          }
        ]
      },
      {
        "file": "/lib/private/Repair.php",
        "line": 123,
        "function": "run",
        "class": "OCA\\Accessibility\\Migration\\RepairUserConfig",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\Repair"
          }
        ]
      },
      {
        "file": "/lib/private/legacy/OC_App.php",
        "line": 1059,
        "function": "run",
        "class": "OC\\Repair",
        "type": "->",
        "args": []
      },
      {
        "file": "/lib/private/legacy/OC_App.php",
        "line": 996,
        "function": "executeRepairSteps",
        "class": "OC_App",
        "type": "::",
        "args": [
          "*** sensitive parameter replaced ***",
          {
            "step": "OCA\\Accessibility\\Migration\\RepairUserConfig"
          }
        ]
      },
      {
        "file": "/lib/private/Updater.php",
        "line": 345,
        "function": "updateApp",
        "class": "OC_App",
        "type": "::",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/lib/private/Updater.php",
        "line": 262,
        "function": "doAppUpgrade",
        "class": "OC\\Updater",
        "type": "->",
        "args": []
      },
      {
        "file": "/lib/private/Updater.php",
        "line": 130,
        "function": "doUpgrade",
        "class": "OC\\Updater",
        "type": "->",
        "args": [
          "22.2.0.2",
          "21.0.5.1"
        ]
      },
      {
        "file": "/core/Command/Upgrade.php",
        "line": 241,
        "function": "upgrade",
        "class": "OC\\Updater",
        "type": "->",
        "args": []
      },
      {
        "file": "/3rdparty/symfony/console/Command/Command.php",
        "line": 255,
        "function": "execute",
        "class": "OC\\Core\\Command\\Upgrade",
        "type": "->",
        "args": [
          {
            "__class__": "Symfony\\Component\\Console\\Input\\ArgvInput"
          },
          {
            "__class__": "Symfony\\Component\\Console\\Output\\ConsoleOutput"
          }
        ]
      },
      {
        "file": "/3rdparty/symfony/console/Application.php",
        "line": 1009,
        "function": "run",
        "class": "Symfony\\Component\\Console\\Command\\Command",
        "type": "->",
        "args": [
          {
            "__class__": "Symfony\\Component\\Console\\Input\\ArgvInput"
          },
          {
            "__class__": "Symfony\\Component\\Console\\Output\\ConsoleOutput"
          }
        ]
      },
      {
        "file": "/3rdparty/symfony/console/Application.php",
        "line": 273,
        "function": "doRunCommand",
        "class": "Symfony\\Component\\Console\\Application",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\Core\\Command\\Upgrade"
          },
          {
            "__class__": "Symfony\\Component\\Console\\Input\\ArgvInput"
          },
          {
            "__class__": "Symfony\\Component\\Console\\Output\\ConsoleOutput"
          }
        ]
      },
      {
        "file": "/3rdparty/symfony/console/Application.php",
        "line": 149,
        "function": "doRun",
        "class": "Symfony\\Component\\Console\\Application",
        "type": "->",
        "args": [
          {
            "__class__": "Symfony\\Component\\Console\\Input\\ArgvInput"
          },
          {
            "__class__": "Symfony\\Component\\Console\\Output\\ConsoleOutput"
          }
        ]
      },
      {
        "file": "/lib/private/Console/Application.php",
        "line": 209,
        "function": "run",
        "class": "Symfony\\Component\\Console\\Application",
        "type": "->",
        "args": [
          {
            "__class__": "Symfony\\Component\\Console\\Input\\ArgvInput"
          },
          {
            "__class__": "Symfony\\Component\\Console\\Output\\ConsoleOutput"
          }
        ]
      },
      {
        "file": "/console.php",
        "line": 99,
        "function": "run",
        "class": "OC\\Console\\Application",
        "type": "->",
        "args": []
      },
      {
        "file": "/occ",
        "line": 11,
        "args": [
          "/console.php"
        ],
        "function": "require_once"
      }
    ],
    "File": "/lib/private/Log/ErrorHandler.php",
    "Line": 92,
    "CustomMessage": "--"
  },
  "id": "615798b00b832"
}

@solracsf
Copy link
Member

solracsf commented Oct 1, 2021

$ find . | grep ProgressBar
./3rdparty/symfony/console/Helper/ProgressBar.php

@fenvarien

This comment has been minimized.

@kesselb kesselb removed the needs info label Oct 2, 2021
@fwolfst

This comment has been minimized.

@fwolfst

This comment has been minimized.

@solracsf solracsf changed the title 22.2.0 Upgrade Error - ValueError: str_repeat(): Argument #2 ($times) must be greater than or equal to 0 Upgrade Error - ValueError: str_repeat(): Argument #2 ($times) must be greater than or equal to 0 Nov 4, 2021
@solracsf

This comment has been minimized.

@kinimodmeyer

This comment has been minimized.

@solracsf
Copy link
Member

solracsf commented Nov 19, 2021

Yes, the upgrade goes on with occ upgrade, but apps aren't re-enabled if they need an upgrade (which is very often the case when upgrading major versions). They remain disabled (groupfolders, talk, externalsites...).

I can only (always) trown this on major upgrades (21>22) not on minor.

@kinimodmeyer
Copy link
Author

The correct workaround to not run into that mentioned problem is:

  1. Run updater.phar
  2. When you get asked to execute "occ upgrade" you say "no".
  3. Now you call directly the occ upgrade command on cli.

In that case you not get that error. Apps get disabled / enabled on step 3.

@solracsf
Copy link
Member

solracsf commented Nov 19, 2021

Ok i'll give it a try, as I was running updater.phar --no-interaction (no questions like "Do you want to execute occ upgrade").

EDIT: confirmed #29023 (comment) is working as workaround, thanks.

@LordSimal
Copy link

LordSimal commented Dec 5, 2021

I also just upgraded from 22.2.3 to 23.0.0 and ran into that error via running updater.phar and confirming an automatic occ upgrade. It was also fixed via manually running occ upgrade afterwards again.
You can see the full upgrade log here occ_upgrade_error.txt
Running on PHP 8.0.13

@dmothes
Copy link

dmothes commented Jan 20, 2022

I wanted to go from 22.1.0.1 to 22.2.3.0, in my place the 'app/mail' has a problem.
Bypass the app, and afterward the upgrade runs trough.
sudo -u http php occ config:app:set --value '1' mail migration_bypass

error-upgrade.txt

@skjnldsv
Copy link
Member

skjnldsv commented Mar 24, 2022

For everyone having that issue, can you all confirm by voting with 👍 that you are running php 8?

cc @kinimodmeyer @solracsf @kesselb @fenvarien @fwolfst @LordSimal @dmothes @herndlm @jaakristioja @KatsuroKurosaki @z3ntu @VeijoPesonen @devi69 @Musikolo

@PVince81
Copy link
Member

got this today on php8 also.
I think it's also the first time I run an upgrade with php 8

@PVince81
Copy link
Member

observed the following: the issue happened when occ upgrade was run through updater.phar (ran through Ansible).
I did a second run manually on the cli, running "occ upgrade" manually and the error disappeared

I'm wondering if updater.phar itself is running the command in a shell environment not properly configured so that the progress bar would fail ?

@ChristophWurst
Copy link
Member

Comparing three different such reports I see that this is caused by startProgress, advance and finishProgress. They all go into https://github.com/nextcloud/3rdparty/blob/fd0d5d72f48315cc4f51342dc2d9e82d1dafe0e8/symfony/console/Helper/ProgressBar.php#L496-L497 and that blows up. So the first line has to evaluate to a negative number when this happens.

@ChristophWurst
Copy link
Member

ChristophWurst commented Apr 7, 2022

I think I could narrow it down. It's our custom formatter that we use during the upgrade:

if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
// Prepend each line with a little timestamp
$timestampFormatter = new TimestampFormatter($this->config, $output->getFormatter());
$output->setFormatter($timestampFormatter);
}
.

If I adjust the occ maintenance:repair command to use the same formatter, the RemoveDeletedUsersCalendarSubscriptions repair step fails with the error mentioned above.

I'm having a closer look with the debugger.

Edit: bingo

Bildschirmfoto vom 2022-04-07 14-33-41

@ChristophWurst ChristophWurst added 3. to review Waiting for reviews 22-feedback and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Apr 7, 2022
@ChristophWurst ChristophWurst self-assigned this Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
Development

Successfully merging a pull request may close this issue.

10 participants