After update, validation error: Invalid number, expected digit but got: "N"

Created on 4 July 2024, 6 months ago
Updated 8 July 2024, 6 months ago

Problem/Motivation

After composer update, GraphQL server stops working, with error:
`Syntax Error: Invalid number, expected digit but got: "N"`

In GraphQL Server, editing the Server with GraphQL Compose, and visiting tabs "Explorer" or "Voyager" doesn't work, with the same error as above. The "Validation" tab displays `Invalid number, expected digit but got: "N"`

However, changing the GraphQL Server Schema to "Composable Schema" allows to visit tabs "Explorer" and "Voyager" (although without data, as I don't have a manual "Composable Schema".
(Note: seems like the webonyx-php Explorer has changed, as its layout is very different from before)

I'm guessing that there was a change on the Schema, and that the "GraphQL Compose schema" needs some adjustment?
It can also be a bug from Drupal GraphQL module itself, but I'm not really sure, as changing the above seems to touch the issue.

The full error, as displayed on Drupal Log Messages:

GraphQL\Error\SyntaxError: Syntax Error: Invalid number, expected digit but got: "N" in GraphQL\Language\Lexer->readDigits() (line 439 of /vendor/webonyx/graphql-php/src/Language/Lexer.php).

Location:
https://[domain]/en/admin/config/graphql/servers/manage/graphql_compose_server/explorer

Referer:
https://[domain]/en/admin/config/graphql/servers/manage/graphql_compose_server?destination=/en/admin/config/graphql

Backtrace:
#0 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Lexer.php(381): GraphQL\Language\Lexer->readDigits()
#1 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Lexer.php(266): GraphQL\Language\Lexer->readNumber()
#2 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Lexer.php(124): GraphQL\Language\Lexer->readToken()
#3 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Lexer.php(116): GraphQL\Language\Lexer->lookahead()
#4 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Parser.php(361): GraphQL\Language\Lexer->advance()
#5 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Parser.php(463): GraphQL\Language\Parser->expect()
#6 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Parser.php(1454): GraphQL\Language\Parser->parseName()
#7 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Parser.php(1438): GraphQL\Language\Parser->parseEnumValueDefinition()
#8 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Parser.php(448): GraphQL\Language\Parser->GraphQL\Language\{closure}()
#9 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Parser.php(1435): GraphQL\Language\Parser->many()
#10 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Parser.php(1417): GraphQL\Language\Parser->parseEnumValuesDefinition()
#11 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Parser.php(1110): GraphQL\Language\Parser->parseEnumTypeDefinition()
#12 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Parser.php(524): GraphQL\Language\Parser->parseTypeSystemDefinition()
#13 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Parser.php(484): GraphQL\Language\Parser->parseDefinition()
#14 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Parser.php(450): GraphQL\Language\Parser->GraphQL\Language\{closure}()
#15 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Parser.php(481): GraphQL\Language\Parser->many()
#16 /var/www/vhosts/[projectFolder]/[domain]/vendor/webonyx/graphql-php/src/Language/Parser.php(192): GraphQL\Language\Parser->parseDocument()
#17 /var/www/vhosts/[projectFolder]/[domain]/web/modules/contrib/graphql/src/Plugin/GraphQL/Schema/AlterableComposableSchema.php(136): GraphQL\Language\Parser::parse()
#18 /var/www/vhosts/[projectFolder]/[domain]/web/modules/contrib/graphql/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php(123): Drupal\graphql\Plugin\GraphQL\Schema\AlterableComposableSchema->getSchemaDocument()
#19 /var/www/vhosts/[projectFolder]/[domain]/web/modules/contrib/graphql/src/Entity/Server.php(253): Drupal\graphql\Plugin\GraphQL\Schema\SdlSchemaPluginBase->getSchema()
#20 /var/www/vhosts/[projectFolder]/[domain]/web/modules/contrib/graphql/src/Entity/Server.php(199): Drupal\graphql\Entity\Server->configuration()
#21 /var/www/vhosts/[projectFolder]/[domain]/web/modules/contrib/graphql/src/GraphQL/Utility/Introspection.php(27): Drupal\graphql\Entity\Server->executeOperation()
#22 /var/www/vhosts/[projectFolder]/[domain]/web/modules/contrib/graphql/src/Controller/ExplorerController.php(87): Drupal\graphql\GraphQL\Utility\Introspection->introspect()
#23 [internal function]: Drupal\graphql\Controller\ExplorerController->viewExplorer()
#24 /var/www/vhosts/[projectFolder]/[domain]/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#25 /var/www/vhosts/[projectFolder]/[domain]/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#26 /var/www/vhosts/[projectFolder]/[domain]/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#27 /var/www/vhosts/[projectFolder]/[domain]/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#28 /var/www/vhosts/[projectFolder]/[domain]/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#29 /var/www/vhosts/[projectFolder]/[domain]/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#30 /var/www/vhosts/[projectFolder]/[domain]/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#31 /var/www/vhosts/[projectFolder]/[domain]/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#32 /var/www/vhosts/[projectFolder]/[domain]/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#33 /var/www/vhosts/[projectFolder]/[domain]/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle()
#34 /var/www/vhosts/[projectFolder]/[domain]/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#35 /var/www/vhosts/[projectFolder]/[domain]/vendor/asm89/stack-cors/src/Cors.php(53): Drupal\page_cache\StackMiddleware\PageCache->handle()
#36 /var/www/vhosts/[projectFolder]/[domain]/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Asm89\Stack\Cors->handle()
#37 /var/www/vhosts/[projectFolder]/[domain]/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#38 /var/www/vhosts/[projectFolder]/[domain]/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#39 /var/www/vhosts/[projectFolder]/[domain]/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#40 /var/www/vhosts/[projectFolder]/[domain]/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#41 /var/www/vhosts/[projectFolder]/[domain]/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#42 {main}

Steps to reproduce

Update Drupal to 10.3.1, GraphQL Compose to 2.1.1, Drupal Graphql to 4.8

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

2.2

Component

Code

Created by

πŸ‡΅πŸ‡ΉPortugal bmateus

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

Merge Requests

Comments & Activities

  • Issue created by @bmateus
  • πŸ‡¦πŸ‡ΊAustralia almunnings Melbourne, πŸ‡¦πŸ‡Ί

    πŸ‘€

  • Status changed to Postponed: needs info 6 months ago
  • πŸ‡¦πŸ‡ΊAustralia almunnings Melbourne, πŸ‡¦πŸ‡Ί

    From what I can gather, its something to do with your schema having a field with a hyphen in the field.
    EG

    type Whatever {
      ti-tle: String
    }
    
    GraphQL\Error\SyntaxError: Syntax Error: Invalid number, expected digit but got: "t" in GraphQL\Language\Lexer->readDigits() (line 439 of /app/vendor/webonyx/graphql-php/src/Language/Lexer.php).

    Do you have any custom schema or config with a hyphen in the field?

    I try to prevent you ever using dashes.
    It might be something custom or overridden?

    Please attach your graphql compose yml and check for any contrib in graphql that might have a field with `-N` in the name.

  • πŸ‡΅πŸ‡ΉPortugal bmateus

    Thanks for taking a look so soon.

    I don't have any schema, am only using GraphQl Compose.

    This happened on production. However, today I've tried to replicate the issue on a blank Lando box, but was unable to.

    That left me scratching my head, and I've disabled all Entities on Graphql compose, just to make sure. I have about 60, between Content Types, Media, Paragraphs, Taxonomies, Menus and more.

    And found out the culprit: Disabling the Menu removed the error and made everything working again.

    As this Menu had some custom fields, I will now investigate further what was causing the issue.

    Most likely I've done a mistake somewhere, and I guess the updated GraphQl became stricter on checking data (which is a good thing, IMO).

    I'm sorry for troubling you. Thank you so much for you suport.

    I'll report back as soon as I have found the exact thing that generated the error, so others can read about it too.

  • I'm having the exact same issue, this only appeared after the graphql 8.x-4.8 update.

  • πŸ‡¦πŸ‡ΊAustralia almunnings Melbourne, πŸ‡¦πŸ‡Ί

    Could either of you attach some config please.

  • I don't have any configs to attach.

    Further to bmateus's tests on menus I have found this:

    I did a compete fresh install:

    Drupal: 10.3.1
    GraphQL: 8.x-4.8
    GraphQL compose: 2.1.1

    1) If you enable the "GraphQL Compose: Menus" sub module and create a new menu that has non single word machine name. For example:

    Create a menu called "Test menu" (the machine name automatically given by Drupal will be "test-menu".

    2) Enable the menu in /admin/config/graphql_compose

    3) Going to the Exploer will fail: /admin/config/graphql/servers/manage/graphql_compose_server/explorer

    GraphQL\Error\SyntaxError: Syntax Error: Invalid number, expected digit but got: "T" in GraphQL\Language\Lexer->readDigits() (line 439 of /opt/drupal/vendor/webonyx/graphql-php/src/Language/Lexer.php).

    On our production server we have tons of menus named like "PT - Footer menu" which ends up having a machine name with name dashes (PT---footer-menu). This causes a slightly different error:

    GraphQL\Error\SyntaxError: Syntax Error: Invalid number, expected digit but got: "-" in GraphQL\Language\Lexer->readDigits() (line 439 of /opt/drupal/vendor/webonyx/graphql-php/src/Language/Lexer.php).

  • πŸ‡¦πŸ‡ΊAustralia almunnings Melbourne, πŸ‡¦πŸ‡Ί

    Got it, thanks that’s really helpful

  • Assigned to almunnings
  • Status changed to Active 6 months ago
  • πŸ‡¦πŸ‡ΊAustralia almunnings Melbourne, πŸ‡¦πŸ‡Ί
  • πŸ‡¦πŸ‡ΊAustralia almunnings Melbourne, πŸ‡¦πŸ‡Ί

    Cool,
    Reproduced, test altered, patch in MR against 2.2.x

    Assuming this goes well, i'll release 2.2

  • πŸ‡¦πŸ‡ΊAustralia almunnings Melbourne, πŸ‡¦πŸ‡Ί

    MR passing tests
    Merging to 2.2.x and creating backport patch to get y'all through til tomorrow and I can release not on a laptop in bed :D

  • Merge request !89Resolve #3459115 2.1.x backport β†’ (Merged) created by almunnings
  • Lol thank you for working on it so quickly and at such a late hour. It's much appreciated. Have a good night.

  • Status changed to Fixed 6 months ago
  • πŸ‡¦πŸ‡ΊAustralia almunnings Melbourne, πŸ‡¦πŸ‡Ί
  • Status changed to Fixed 6 months ago
  • πŸ‡¦πŸ‡ΊAustralia almunnings Melbourne, πŸ‡¦πŸ‡Ί
Production build 0.71.5 2024