Skip to content

ProductUrlSuffix and CategoryUrlSuffix GraphQL resolvers fail with null values #30909

Closed
@aligent-lturner

Description

@aligent-lturner

Preconditions (*)

  1. Magento version 2.4.x
  2. Magento 2.4-develop

Steps to reproduce (*)

  1. Go to Admin -> Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization
  2. Clear product and category url suffix values in admin and save

Screenshot from 2020-11-20 15-24-20

Run GraphQL query that requests product and/or category url suffix value

{
  categoryList {
    url_suffix
  }
}

Expected result: Empty string ('') is returned for url_suffix value

Screenshot from 2020-11-20 15-40-01

Actual Result: ✖️ Query fails

Screenshot from 2020-11-20 15-29-15

✖️ with the following error in exception.log:

2020-11-20 13:29:04] main.ERROR: Return value of Magento\CatalogUrlRewriteGraphQl\Model\Resolver\CategoryUrlSuffix::getCategoryUrlSuffix() must be of the type string, null returned {"exception":"[object] (GraphQL\\Error\\Error(code: 0): Return value of Magento\\CatalogUrlRewriteGraphQl\\Model\\Resolver\\CategoryUrlSuffix::getCategoryUrlSuffix() must be of the type string, null returned at /var/www/html/magento24/vendor/webonyx/graphql-php/src/Error/Error.php:174, TypeError(code: 0): Return value of Magento\\CatalogUrlRewriteGraphQl\\Model\\Resolver\\CategoryUrlSuffix::getCategoryUrlSuffix() must be of the type string, null returned at /var/www/html/magento24/app/code/Magento/CatalogUrlRewriteGraphQl/Model/Resolver/CategoryUrlSuffix.php:80)"} []

Additional Information

The problem is that the private functions getProductUrlSuffix and getCategoryUrlSuffix are declared with string as the return type, but when values are cleared in admin config, null gets stored in the core_config_data table. The value being returned by ScopeConfigInterface->getValue should be checked for null and changed to empty string instead.
I will create PR to fix this.


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Labels

Component: GraphQLGraphQLFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: ready for confirmationPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReported on 2.4.xIndicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions