From b609bf096bae18a1ebbf47b7cafd77635241e085 Mon Sep 17 00:00:00 2001 From: Edward Ly Date: Tue, 15 Sep 2026 08:53:34 -0700 Subject: [PATCH] fix(Command): catch InvalidArgumentException if `login-name` option doesn't exist Signed-off-by: Edward Ly --- core/Command/User/AuthTokens/Add.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/Command/User/AuthTokens/Add.php b/core/Command/User/AuthTokens/Add.php index c491ced011bf6..83ea51223338b 100644 --- a/core/Command/User/AuthTokens/Add.php +++ b/core/Command/User/AuthTokens/Add.php @@ -16,6 +16,7 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\Security\ISecureRandom; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -92,7 +93,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $password = $helper->ask($input, $output, $question); } - $loginName = $input->getOption('login-name') ?? $user->getUID(); + try { + $loginName = $input->getOption('login-name') ?? $user->getUID(); + } catch (InvalidArgumentException) { + $loginName = $user->getUID(); + } if ($password === null) { $output->writeln('No password provided. The generated app password will therefore have limited capabilities. Any operation that requires the login password will fail.');