From fa2c09fb623d685bfb6d5a24bdde1ada805554b1 Mon Sep 17 00:00:00 2001 From: Deepak Kumar Mishra Date: Thu, 30 Jul 2026 13:15:50 +0530 Subject: [PATCH 1/2] IDE-5298: Improve federated auth error message to include AH_ORGANIZATION_UUID guidance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The existing hint only said "Run acli login" which was incomplete — users also need AH_ORGANIZATION_UUID exported first, and the order matters. Branch the help message on whether the env var is already set so Cloud IDE users (where the var is injected) get a different prompt than standalone users. Co-Authored-By: Claude Sonnet 4.6 --- src/EventListener/ExceptionListener.php | 7 +++- .../src/Misc/ExceptionListenerTest.php | 35 ++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/EventListener/ExceptionListener.php b/src/EventListener/ExceptionListener.php index 66850b94..21c77733 100644 --- a/src/EventListener/ExceptionListener.php +++ b/src/EventListener/ExceptionListener.php @@ -94,7 +94,12 @@ public function onConsoleError(ConsoleErrorEvent $event): void break; case "This resource requires additional authentication.": $this->helpMessages[] = "This is likely because you have Federated Authentication required for your organization."; - $this->helpMessages[] = "Run `acli login` to authenticate via API token and then try again."; + if (getenv('AH_ORGANIZATION_UUID')) { + $this->helpMessages[] = "`AH_ORGANIZATION_UUID` is already set in your environment. Run `acli auth:login` to configure API credentials, then retry."; + } else { + $this->helpMessages[] = "First, export your organization UUID: `export AH_ORGANIZATION_UUID=`. Find your UUID at https://cloud.acquia.com/a/organizations"; + $this->helpMessages[] = "Then run `acli auth:login` to configure API credentials and retry."; + } $this->helpMessages[] = "Get help for this error at https://docs.acquia.com/acquia-cloud-platform/add-ons/acquia-cli/known-issues#federated-authentication-does-not-work"; break; default: diff --git a/tests/phpunit/src/Misc/ExceptionListenerTest.php b/tests/phpunit/src/Misc/ExceptionListenerTest.php index ec86753b..523caee3 100644 --- a/tests/phpunit/src/Misc/ExceptionListenerTest.php +++ b/tests/phpunit/src/Misc/ExceptionListenerTest.php @@ -11,6 +11,7 @@ use AcquiaCloudApi\Exception\ApiErrorException; use League\OAuth2\Client\Provider\Exception\IdentityProviderException; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Event\ConsoleErrorEvent; use Symfony\Component\Console\Exception\RuntimeException; @@ -127,7 +128,8 @@ public static function providerTestHelp(): array ]), [ 'This is likely because you have Federated Authentication required for your organization.', - 'Run `acli login` to authenticate via API token and then try again.', + 'First, export your organization UUID: `export AH_ORGANIZATION_UUID=`. Find your UUID at https://cloud.acquia.com/a/organizations', + 'Then run `acli auth:login` to configure API credentials and retry.', 'Get help for this error at https://docs.acquia.com/acquia-cloud-platform/add-ons/acquia-cli/known-issues#federated-authentication-does-not-work', ], ], @@ -150,4 +152,35 @@ public static function providerTestHelp(): array ], ]; } + + #[Group('serial')] + public function testFederatedAuthHelpWithOrgUuidAlreadySet(): void + { + putenv('AH_ORGANIZATION_UUID=647fb0ca-8903-4e45-bbca-9472d8efafcb'); + try { + $exceptionListener = new ExceptionListener(); + $commandProphecy = $this->prophet->prophesize(Command::class); + $applicationProphecy = $this->prophet->prophesize(Application::class); + $messages = [ + 'How to fix it: This is likely because you have Federated Authentication required for your organization.', + '`AH_ORGANIZATION_UUID` is already set in your environment. Run `acli auth:login` to configure API credentials, then retry.', + 'Get help for this error at https://docs.acquia.com/acquia-cloud-platform/add-ons/acquia-cli/known-issues#federated-authentication-does-not-work', + 'You can find Acquia CLI documentation at https://docs.acquia.com/acquia-cli/', + 'You can submit a support ticket at https://support-acquia.force.com/s/contactsupport' . PHP_EOL . 'Re-run the command with the -vvv flag and include the full command output in your support ticket.', + ]; + $applicationProphecy->setHelpMessages($messages)->shouldBeCalled(); + $commandProphecy->getApplication()->willReturn($applicationProphecy->reveal()); + $commandProphecy->getName()->willReturn('ide:wizard:ssh-key:create-upload'); + $error = new ApiErrorException((object) [ + 'error' => '', + 'message' => 'This resource requires additional authentication.', + ]); + $consoleErrorEvent = new ConsoleErrorEvent($this->input, $this->output, $error, $commandProphecy->reveal()); + $exceptionListener->onConsoleError($consoleErrorEvent); + $this->prophet->checkPredictions(); + self::assertTrue(true); + } finally { + putenv('AH_ORGANIZATION_UUID'); + } + } } From 017c7c11408aa71454e6f997b380972b6df961ee Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 30 Jul 2026 08:04:49 +0000 Subject: [PATCH 2/2] IDE-5298: Replace unsafe style tag placeholder with YOUR_ORG_UUID --- src/EventListener/ExceptionListener.php | 2 +- tests/phpunit/src/Misc/ExceptionListenerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EventListener/ExceptionListener.php b/src/EventListener/ExceptionListener.php index 21c77733..e5f9b580 100644 --- a/src/EventListener/ExceptionListener.php +++ b/src/EventListener/ExceptionListener.php @@ -97,7 +97,7 @@ public function onConsoleError(ConsoleErrorEvent $event): void if (getenv('AH_ORGANIZATION_UUID')) { $this->helpMessages[] = "`AH_ORGANIZATION_UUID` is already set in your environment. Run `acli auth:login` to configure API credentials, then retry."; } else { - $this->helpMessages[] = "First, export your organization UUID: `export AH_ORGANIZATION_UUID=`. Find your UUID at https://cloud.acquia.com/a/organizations"; + $this->helpMessages[] = "First, export your organization UUID: `export AH_ORGANIZATION_UUID=YOUR_ORG_UUID`. Find your UUID at https://cloud.acquia.com/a/organizations"; $this->helpMessages[] = "Then run `acli auth:login` to configure API credentials and retry."; } $this->helpMessages[] = "Get help for this error at https://docs.acquia.com/acquia-cloud-platform/add-ons/acquia-cli/known-issues#federated-authentication-does-not-work"; diff --git a/tests/phpunit/src/Misc/ExceptionListenerTest.php b/tests/phpunit/src/Misc/ExceptionListenerTest.php index 523caee3..9c7e3e3f 100644 --- a/tests/phpunit/src/Misc/ExceptionListenerTest.php +++ b/tests/phpunit/src/Misc/ExceptionListenerTest.php @@ -128,7 +128,7 @@ public static function providerTestHelp(): array ]), [ 'This is likely because you have Federated Authentication required for your organization.', - 'First, export your organization UUID: `export AH_ORGANIZATION_UUID=`. Find your UUID at https://cloud.acquia.com/a/organizations', + 'First, export your organization UUID: `export AH_ORGANIZATION_UUID=YOUR_ORG_UUID`. Find your UUID at https://cloud.acquia.com/a/organizations', 'Then run `acli auth:login` to configure API credentials and retry.', 'Get help for this error at https://docs.acquia.com/acquia-cloud-platform/add-ons/acquia-cli/known-issues#federated-authentication-does-not-work', ],