Getting this error even if key is set

Created on 15 December 2023, 11 months ago
Updated 14 May 2024, 6 months ago

PHP Fatal error: Uncaught Error: Typed property Drupal\jwt\Transcoder\JwtTranscoder::$algorithmType must not be accessed before initialization in /var/www/drupal/web/modules/contrib/jwt/src/Transcoder/JwtTranscoder.php:257
Stack trace:
#0 /var/www/drupal/web/modules/contrib/jwt/src/Transcoder/JwtTranscoder.php(237): Drupal\jwt\Transcoder\JwtTranscoder->getKey()
#1 /var/www/drupal/web/modules/contrib/jwt/src/Authentication/Provider/JwtAuth.php(100): Drupal\jwt\Transcoder\JwtTranscoder->encode()
#2 /var/www/drupal/web/modules/contrib/islandora/src/Flysystem/Fedora.php(117): Drupal\jwt\Authentication\Provider\JwtAuth->generateToken()
#3 /var/www/drupal/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(35): Drupal\islandora\Flysystem\Fedora::Drupal\islandora\Flysystem\{closure}()
#4 /var/www/drupal/vendor/guzzlehttp/guzzle/src/Middleware.php(31): GuzzleHttp\PrepareBodyMiddleware->__invoke()
#5 /var/www/drupal/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(71): GuzzleHttp\Middleware::GuzzleHttp\{closure}()
#6 /var/www/drupal/vendor/guzzlehttp/guzzle/src/Middleware.php(63): GuzzleHttp\RedirectMiddleware->__invoke()
#7 /var/www/drupal/vendor/guzzlehttp/guzzle/src/HandlerStack.php(75): GuzzleHttp\Middleware::GuzzleHttp\{closure}()
#8 /var/www/drupal/vendor/guzzlehttp/guzzle/src/Client.php(333): GuzzleHttp\HandlerStack->__invoke()
#9 /var/www/drupal/vendor/guzzlehttp/guzzle/src/Client.php(169): GuzzleHttp\Client->transfer()
#10 /var/www/drupal/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\Client->requestAsync()
#11 /var/www/drupal/vendor/islandora/chullo/src/FedoraApi.php(116): GuzzleHttp\Client->request()
#12 /var/www/drupal/web/modules/contrib/islandora/src/Flysystem/Fedora.php(136): Islandora\Chullo\FedoraApi->getResourceHeaders()
#13 /var/www/drupal/web/modules/contrib/flysystem/src/FlysystemFactory.php(182): Drupal\islandora\Flysystem\Fedora->ensure()
#14 /var/www/drupal/web/modules/contrib/flysystem/flysystem.module(26): Drupal\flysystem\FlysystemFactory->ensure()
#15 [internal function]: flysystem_rebuild()
#16 /var/www/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(409): call_user_func_array()
#17 /var/www/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}()
#18 /var/www/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(416): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
#19 /var/www/drupal/web/core/includes/common.inc(510): Drupal\Core\Extension\ModuleHandler->invokeAll()
#20 /var/www/drupal/web/core/includes/utility.inc(41): drupal_flush_all_caches()
#21 /var/www/drupal/vendor/drush/drush/src/Commands/core/CacheRebuildCommands.php(66): drupal_rebuild()
#22 [internal function]: Drush\Commands\core\CacheRebuildCommands->rebuild()
#23 /var/www/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array()
#24 /var/www/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
#25 /var/www/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
#26 /var/www/drupal/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(391): Consolidation\AnnotatedCommand\CommandProcessor->process()
#27 /var/www/drupal/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
#28 /var/www/drupal/vendor/symfony/console/Application.php(1081): Symfony\Component\Console\Command\Command->run()
#29 /var/www/drupal/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand()
#30 /var/www/drupal/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun()
#31 /var/www/drupal/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run()
#32 /var/www/drupal/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
#33 /var/www/drupal/vendor/drush/drush/drush.php(139): Drush\Runtime\Runtime->run()
#34 /var/www/drupal/vendor/drush/drush/drush(4): require('/var/www/drupal...')
#35 /var/www/drupal/vendor/bin/drush(120): include('/var/www/drupal...')
#36 {main}
thrown in /var/www/drupal/web/modules/contrib/jwt/src/Transcoder/JwtTranscoder.php on line 257
[warning] Drush command terminated abnormally.

๐Ÿ› Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States borwickja

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @borwickja
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States grasmash

    I'd consider this a bug -- there should be a clear error message. But, you can resolve this by creating a key as per the instruction on the project page:

    Signing and/or validating JWTs requires a secret. The JWT module leverages the key module to manage these secrets. Once everything is installed, you will need to create a new key at Manage > Configuration > System > Keys (admin/config/system/keys). Add a new or existing key there.

    and

    Once you have created a key, navigate to Configuration > System > JWT Authentication (admin/config/system/jwt). Choose the key that you just created in the previous step.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia abhishek_virasat

    abhishek_gupta1 โ†’ made their first commit to this issueโ€™s fork.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 10 months ago
    12 pass
  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia abhishek_virasat

    @borwickja, i have fixed the issue and created MR. please kindly review the MR

  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States pwolanin

    The logic change looks ok, but you changed the code style to be incorrect:

    12 coding standards messages
    โœ— 12 more than branch result
    
    src/Transcoder/JwtTranscoder.php โœ— 12 more
    line 261	Line indented incorrectly; expected 6 spaces, found 8
    262	Expected newline after closing brace
    263	Line indented incorrectly; expected 6 spaces, found 8
    264	Line indented incorrectly; expected 8 spaces, found 12
    265	Line indented incorrectly; expected 6 spaces, found 8
    265	Expected newline after closing brace
    266	Line indented incorrectly; expected 8 spaces, found 12
    267	Line indented incorrectly; expected 6 spaces, found 8
    271	Line indented incorrectly; expected 2 spaces, found 0
    271	Closing brace indented incorrectly; expected 2 spaces, found 0
    271	Expected 1 blank line after function; 2 found
    274	The closing brace for the class must have an empty line before it
    
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany broon Potsdam

    Apart from the coding style issues, this MR resolves the problems for me when running PHPUnit tests on custom modules (requiring JWT functionality).

Production build 0.71.5 2024