pantheon-systems / search_api_pantheon

ApachSolr on Pantheon for Drupal 8/9 via Search API
https://pantheon.io
MIT License
7 stars 23 forks source link

Drush `search-api-pantheon:diagnose` fails #179

Open paulsheldrake opened 1 month ago

paulsheldrake commented 1 month ago

Describe the bug Running drush search-api-pantheon:diagnose generates an error

To Reproduce Drupal: 10.2.6
Install search_api_pantheon: 8.1.8 PHP: 8.2

fin drush  search-api-pantheon:diagnose                               

┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ $t                                                                                                                                                                            │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
TypeError (7) (
    protected 'message' -> string (141) "Drush\Commands\DrushCommands::logger(): Return value must be of type ?Drush\Log\DrushLoggerManager, Drupal\Core\Logger\LoggerChannel returned"
    private 'string' -> string (0) ""
    protected 'code' -> integer 0
    protected 'file' -> string (58) "/var/www/vendor/drush/drush/src/Commands/DrushCommands.php"
    protected 'line' -> integer 85
    private 'trace' -> Debug Backtrace (15):
        1:  <ROOT>/web/modules/contrib/search_api_pantheon/src/Commands/Diagnose.php:105
            Drush\Commands\DrushCommands::logger()

                // If still empty, throw an exception.
                throw new \Exception('Unable to find search.version in pantheon.yml or pantheon.upstream.yml');
              }

              if ($pantheon_yml['search']['version'] != '8') {
                throw new \Exception('Unsupported search.version in pantheon.yml or pantheon.upstream.yml');
              }
              $this->logger()->notice('Pantheon.yml file looks ok ✅');

              $this->logger()->notice('Index SCHEME Value: {var}', [
                    'var' => $this->endpoint->getScheme(),
                ]);
              $this->logger()->notice('Index HOST Value:   {var}', [
                    'var' => $this->endpoint->getHost(),
                ]);
        2:  PHP internal call
            Drupal\search_api_pantheon\Commands\Diagnose::diagnose()

        3:  <ROOT>/vendor/consolidation/annotated-command/src/CommandProcessor.php:276
            call_user_func_array(callable $callback, array $args)

             * Run the main command callback
             */
            protected function runCommandCallback($commandCallback, CommandData $commandData)
            {
                $result = false;
                try {
                    $args = $this->parameterInjection()->args($commandData);
                    $result = call_user_func_array($commandCallback, array_values($args));
                } catch (\Exception $e) {
                    $result = $this->commandErrorForException($e);
                }
                return $result;
            }

            public function injectIntoCommandData($commandData, $injectedClasses)
        4:  <ROOT>/vendor/consolidation/annotated-command/src/CommandProcessor.php:212
            Consolidation\AnnotatedCommand\CommandProcessor::runCommandCallback($commandCallback, Consolidation\AnnotatedCommand\CommandData $commandData)

                    $replaceDispatcher->setLogger($this->logger);
                }
                if ($replaceDispatcher->hasReplaceCommandHook()) {
                    $commandCallback = $replaceDispatcher->getReplacementCommand($commandData);
                }

                // Run the command, alter the results, and then handle output and status
                $result = $this->runCommandCallback($commandCallback, $commandData);
                return $this->processResults($names, $result, $commandData);
            }

            public function processResults($names, $result, CommandData $commandData)
            {
                $processDispatcher = new ProcessResultHookDispatcher($this->hookManager(), $names);
                return $processDispatcher->process($result, $commandData);
        5:  <ROOT>/vendor/consolidation/annotated-command/src/CommandProcessor.php:175
            Consolidation\AnnotatedCommand\CommandProcessor::validateRunAndAlter($names, $commandCallback, Consolidation\AnnotatedCommand\CommandData $commandData)

                OutputInterface $output,
                $names,
                $commandCallback,
                CommandData $commandData
            ) {
                $result = [];
                try {
                    $result = $this->validateRunAndAlter(
                        $names,
                        $commandCallback,
                        $commandData
                    );
                    return $this->handleResults($output, $names, $result, $commandData);
                } catch (\Exception $e) {
                    $result = $this->commandErrorForException($e);
        6:  <ROOT>/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:387
            Consolidation\AnnotatedCommand\CommandProcessor::process(Symfony\Component\Console\Output\OutputInterface $output, $names, $commandCallback, Consolidation\AnnotatedCommand\CommandData $commandData)

            /**
             * {@inheritdoc}
             */
            protected function execute(InputInterface $input, OutputInterface $output): int
            {
                $state = $this->injectIntoCommandfileInstance($input, $output);
                // Validate, run, process, alter, handle results.
                $result = $this->commandProcessor()->process(
                    $output,
                    $this->getNames(),
                    $this->commandCallback,
                    $this->createCommandData($input, $output)
                );
                $state->restore();
                return $result;
        7:  <ROOT>/vendor/symfony/console/Command/Command.php:326
            Consolidation\AnnotatedCommand\AnnotatedCommand::execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output)

                }

                $input->validate();

                if ($this->code) {
                    $statusCode = ($this->code)($input, $output);
                } else {
                    $statusCode = $this->execute($input, $output);

                    if (!\is_int($statusCode)) {
                        throw new \TypeError(sprintf('Return value of "%s::execute()" must be of the type int, "%s" returned.', static::class, get_debug_type($statusCode)));
                    }
                }

                return is_numeric($statusCode) ? (int) $statusCode : 0;
        8:  <ROOT>/vendor/symfony/console/Application.php:1096
            Symfony\Component\Console\Command\Command::run(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output)

                $event = new ConsoleCommandEvent($command, $input, $output);
                $e = null;

                try {
                    $this->dispatcher->dispatch($event, ConsoleEvents::COMMAND);

                    if ($event->commandShouldRun()) {
                        $exitCode = $command->run($input, $output);
                    } else {
                        $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
                    }
                } catch (\Throwable $e) {
                    $event = new ConsoleErrorEvent($input, $output, $e, $command);
                    $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
                    $e = $event->getError();
        9:  <ROOT>/vendor/symfony/console/Application.php:324
            Symfony\Component\Console\Application::doRunCommand(Symfony\Component\Console\Command\Command $command, Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output)

                }

                if ($command instanceof LazyCommand) {
                    $command = $command->getCommand();
                }

                $this->runningCommand = $command;
                $exitCode = $this->doRunCommand($command, $input, $output);
                $this->runningCommand = null;

                return $exitCode;
            }

            /**
             * @return void
        10: <ROOT>/vendor/symfony/console/Application.php:175
            Symfony\Component\Console\Application::doRun(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output)

                        $phpHandler[0]->setExceptionHandler($errorHandler);
                    }
                }

                $this->configureIO($input, $output);

                try {
                    $exitCode = $this->doRun($input, $output);
                } catch (\Throwable $e) {
                    if ($e instanceof \Exception && !$this->catchExceptions) {
                        throw $e;
                    }
                    if (!$e instanceof \Exception && !$this->catchErrors) {
                        throw $e;
                    }
        11: <ROOT>/vendor/drush/drush/src/Runtime/Runtime.php:110
            Symfony\Component\Console\Application::run(?Symfony\Component\Console\Input\InputInterface $input = null, ?Symfony\Component\Console\Output\OutputInterface $output = null)

                // from the search paths we found above.  After this point, the input
                // and output objects are ready & we can start using the logger, etc.
                $application->configureAndRegisterCommands($input, $output, $commandfileSearchpath, $this->preflight->environment()->loader());

                // Run the Symfony Application
                // Predispatch: call a remote Drush command if applicable (via a 'pre-init' hook)
                // Bootstrap: bootstrap site to the level requested by the command (via a 'post-init' hook)
                $status = $application->run($input, $output);

                // Placate the Drush shutdown handler.
                Runtime::setCompleted();
                Runtime::setExitCode($status);

                return $status;
            }
        12: <ROOT>/vendor/drush/drush/src/Runtime/Runtime.php:40
            Drush\Runtime\Runtime::doRun($argv, $output)

             * Typically, this will happen only for code that fails fast during
             * preflight. Later code should catch and handle its own exceptions.
             */
            public function run($argv): int
            {
                try {
                    $output = new ConsoleOutput();
                    $status = $this->doRun($argv, $output);
                } catch (\Exception $e) {
                    // Fallback to status 1 if the Exception has not indicated otherwise.
                    $status = $e->getCode() ?: DrushCommands::EXIT_FAILURE;
                    $message = $e->getMessage();
                    // Uncaught exceptions could happen early, before our logger
                    // and other classes are initialized. Print them and exit.
                    $this->preflight->logger()->setDebug(true)->log($message);
        13: <ROOT>/vendor/drush/drush/drush.php:139
            Drush\Runtime\Runtime::run($argv)

        $environment->applyEnvironment();

        // Preflight and run
        $preflight = new Preflight($environment);
        $di = new DependencyInjection();
        $di->desiredHandlers(['errorHandler', 'shutdownHandler']);
        $runtime = new Runtime($preflight, $di);
        $status_code = $runtime->run($_SERVER['argv']);

        exit($status_code);
        14: <ROOT>/vendor/drush/drush/drush:4
            require(...)

        #!/usr/bin/env php
        <?php

        require __DIR__ . '/drush.php';
        15: <ROOT>/vendor/bin/drush:119
            include(...)

                (function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
                || (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper'))
            ) {
                return include("phpvfscomposer://" . __DIR__ . '/..'.'/drush/drush/drush');
            }
        }

        return include __DIR__ . '/..'.'/drush/drush/drush';
    private 'previous' -> null
)
═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Called from <ROOT>/web/modules/contrib/search_api_pantheon/src/Commands/Diagnose.php:193 [Kint\Kint::dump()]
 [error]  There's a problem somewhere... 
 [warning] Drush command terminated abnormally.
sean-e-dietrich commented 1 month ago

I was able to replicate this with terminus


terminus drush site.dev -- search-api-pantheon:diagnose                                                                                                                                                                                                                                               ```