Skip to content

[Bug] GraphQL SearchCriteriaValidator not loaded — removed by module-graph-ql di.xml array override - #40742

Merged
magento-devops-reposync-svc merged 8 commits into
magento:2.4-developfrom
mtytula:fix/graphql-page-size-limit
May 20, 2026
Merged

magento-devops-reposync-svc merged 8 commits into
magento:2.4-developfrom
mtytula:fix/graphql-page-size-limit

Conversation

@mtytula

@mtytula mtytula commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

Preconditions

  • Magento 2.4.7-p9 (magento/module-graph-ql 100.4.7-p9)
  • Any GraphQL query with pageSize or currentPage arguments

Steps to reproduce

  1. Execute any GraphQL query with pageSize exceeding the configured limit, e.g.:
{
    products(search: "test", pageSize: 999) {
        items {
            sku
        }
    }
}

Expected result

GraphQL returns a validation error:

{
    "data": {
        "products": null
    },
    "errors": [
        {
            "message": "Maximum pageSize is 10",
            "path": [
                "products"
            ],
            "locations": [
                {
                    "line": 2,
                    "column": 5
                }
            ],
            "extensions": {
                "category": "graphql-input"
            }
        }
    ]
}

(Maximum pageSize is X — where X is the configured maxPageSize value, default 300)


Actual result

Query executes without validation. pageSize: 999 is accepted silently. No error is returned.


Root cause

SearchCriteriaValidator (which enforces maxPageSize: 300) is registered
in magento2-base/app/etc/di.xml (primary config):

<!-- magento2-base/app/etc/di.xml -->
<type name="Magento\Framework\GraphQl\Query\Resolver\Argument\Validator\CompositeValidator">
    <arguments>
        <argument name="validators" xsi:type="array">
            <item name="searchCriteriaValidator" xsi:type="object">
                Magento\Framework\GraphQl\Query\Resolver\Argument\Validator\SearchCriteriaValidator
            </item>
        </argument>
    </arguments>
</type>

module-graph-ql/etc/di.xml (module config) also defines validators for the
same type, but only with backpressureValidator:

<!-- module-graph-ql/etc/di.xml -->
<type name="Magento\Framework\GraphQl\Query\Resolver\Argument\Validator\CompositeValidator">
    <arguments>
        <argument name="validators" xsi:type="array">
            <item name="backpressureValidator" xsi:type="object">
                Magento\GraphQl\Model\Backpressure\BackpressureFieldValidator
            </item>
        </argument>
    </arguments>
</type>

Module-level DI configuration has higher priority than primary config.
When module config defines the same xsi:type="array" argument, it replaces
the primary config's array — it does not merge items. As a result,
searchCriteriaValidator is silently dropped.

Verification at runtime:

$validator = $objectManager->get(
    \Magento\Framework\GraphQl\Query\Resolver\Argument\Validator\CompositeValidator::class
);
$ref = new ReflectionClass($validator);
$prop = $ref->getProperty('validators');
$prop->setAccessible(true);
var_dump(array_keys($prop->getValue($validator)));
// Output: ['backpressureValidator']
// Expected: ['searchCriteriaValidator', 'backpressureValidator']

Proposed fix

Move searchCriteriaValidator registration from magento2-base/app/etc/di.xml
to module-graph-ql/etc/di.xml. Both validators should live at module level
so that future validators added by third-party modules can safely merge via
xsi:type="array".

module-graph-ql/etc/di.xml — after fix

<type name="Magento\Framework\GraphQl\Query\Resolver\Argument\Validator\CompositeValidator">
    <arguments>
        <argument name="validators" xsi:type="array">
            <item name="searchCriteriaValidator" xsi:type="object">
                Magento\Framework\GraphQl\Query\Resolver\Argument\Validator\SearchCriteriaValidator
            </item>
            <item name="backpressureValidator" xsi:type="object">
                Magento\GraphQl\Model\Backpressure\BackpressureFieldValidator
            </item>
        </argument>
    </arguments>
</type>

magento2-base/app/etc/di.xml — remove this block

<!-- REMOVE: -->
<type name="Magento\Framework\GraphQl\Query\Resolver\Argument\Validator\CompositeValidator">
    <arguments>
        <argument name="validators" xsi:type="array">
            <item name="searchCriteriaValidator" xsi:type="object">
                Magento\Framework\GraphQl\Query\Resolver\Argument\Validator\SearchCriteriaValidator
            </item>
        </argument>
    </arguments>
</type>

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Temporary workaround (composer patch)

Until the upstream fix is merged — apply a patch via cweagans/composer-patches.

1. composer.json

"extra": {
    "composer-exit-on-patch-failure": true,
    "patches": {
        "magento/module-graph-ql": {
            "Fix search criteria composite validator": "patches/magento/module-graph-ql/fix-search-validator.diff"
        }
    }
}

2. patches/magento/module-graph-ql/fix-search-validator.diff

Index: etc/di.xml
===================================================================
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -107,6 +107,7 @@
     <type name="Magento\Framework\GraphQl\Query\Resolver\Argument\Validator\CompositeValidator">
         <arguments>
             <argument name="validators" xsi:type="array">
+                <item name="searchCriteriaValidator" xsi:type="object">Magento\Framework\GraphQl\Query\Resolver\Argument\Validator\SearchCriteriaValidator</item>
                 <item name="backpressureValidator" xsi:type="object">
                     Magento\GraphQl\Model\Backpressure\BackpressureFieldValidator
                 </item>

3. Apply

composer require cweagans/composer-patches --no-update
composer update magento/module-graph-ql
# or simply:
composer install 

Affected repositories

  • magento/magento2 — app/etc/di.xml (magento2-base)
  • magento/module-graph-ql — etc/di.xml

Affected versions

All versions of magento/module-graph-ql that introduced backpressureValidator
(i.e. all versions that define CompositeValidator type in their etc/di.xml).

Resolved issues:

  1. resolves [Issue] [Bug] GraphQL SearchCriteriaValidator not loaded — removed by module-graph-ql di.xml array override #40762: [Bug] GraphQL SearchCriteriaValidator not loaded — removed by module-graph-ql di.xml array override

@m2-assistant

m2-assistant Bot commented Apr 15, 2026

Copy link
Copy Markdown

Hi @mtytula. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@ct-prd-pr-scan

Copy link
Copy Markdown

The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com.

1 similar comment
@ct-prd-pr-scan

Copy link
Copy Markdown

The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com.

@mtytula mtytula changed the title Fixed search criteria validator [Bug] GraphQL SearchCriteriaValidator not loaded — removed by module-graph-ql di.xml array override Apr 15, 2026
@ct-prd-pr-scan

Copy link
Copy Markdown

The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com.

@mtytula

mtytula commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@ct-prd-pr-scan

Copy link
Copy Markdown

The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com.

1 similar comment
@ct-prd-pr-scan

Copy link
Copy Markdown

The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com.

@engcom-Dash

Copy link
Copy Markdown
Contributor

@magento create issue

@ct-prd-pr-scan

Copy link
Copy Markdown

The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com.

@mtytula

mtytula commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

@magento add to contributors team

@m2-assistant

m2-assistant Bot commented Apr 27, 2026

Copy link
Copy Markdown

Hi @mtytula! 👋
Thank you for joining. Please accept team invitation 👉 here 👈 and add your comment one more time.

@engcom-Hotel

Copy link
Copy Markdown
Contributor

@magento run all tests

@engcom-Hotel engcom-Hotel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @mtytula,

Thank you for the contribution!

The code changes looks good to us and the failed tests seems either flaky or known issues.

But can you please add some automated test in accordance to the DOD.

Thank you

@engcom-Hotel engcom-Hotel moved this from Pending Review to Changes Requested in Community Dashboard May 5, 2026
@engcom-Dash engcom-Dash self-assigned this May 5, 2026
@mtytula

mtytula commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@mtytula

mtytula commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

Hello @mtytula,

Thank you for the contribution!

The code changes looks good to us and the failed tests seems either flaky or known issues.

But can you please add some automated test in accordance to the DOD.

Thank you

Done :)

@ct-prd-pr-scan

ct-prd-pr-scan Bot commented May 6, 2026

Copy link
Copy Markdown

The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com.

1 similar comment
@ct-prd-pr-scan

ct-prd-pr-scan Bot commented May 6, 2026

Copy link
Copy Markdown

The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com.

@mtytula

mtytula commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@mtytula

mtytula commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@mtytula

mtytula commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@engcom-Hotel @engcom-Dash

My tests passed 🚀

@engcom-Hotel engcom-Hotel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @mtytula for making the changes, approving this PR for further process

@engcom-Bravo

Copy link
Copy Markdown
Contributor

Hi @mtytula,

Thanks for the collaboration & contribution!

✔️ QA Passed

Preconditions:

  • Install fresh Magento 2.4-develop

Steps to Reproduce

  • Execute any GraphQL query with pageSize exceeding the configured limit, e.g.:
{
    products(search: "test", pageSize: 999) {
        items {
            sku
        }
    }
}

Before: ✖️ 

Screenshot 2026-05-11 at 2 37 37 PM

After: ✔️

{
  "errors": [
    {
      "message": "Maximum pageSize is 10.",
      "locations": [
        {
          "line": 6,
          "column": 5
        }
      ],
      "path": [
        "products"
      ],
      "extensions": {
        "category": "graphql-input"
      }
    }
  ]

Builds are failed. Hence, moving this PR to Extended Testing.

Thanks.

@engcom-Bravo engcom-Bravo moved this from Testing in Progress to Extended testing (optional) in Community Dashboard May 11, 2026
@engcom-Dash

Copy link
Copy Markdown
Contributor

@magento run all tests

@engcom-Dash

Copy link
Copy Markdown
Contributor

@magento run Unit Tests

@engcom-Dash

Copy link
Copy Markdown
Contributor

A few of the Functional and Web API failures are not consistent in the recent 2 builds. They are neither failing because of the PR nor part of the PR, considered to be flaky. The consistent failures are known issues, hence moving this PR to Merge in Progress.

CE
Build 1
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40742/8849ad1ff0e9ff8517f305f6bc1c7028/Functional/allure-report-ce/index.html#categories
image

Build 2
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40742/7f8a48c661e2d8f513590bdf3f4d6ec5/Functional/allure-report-ce/index.html#categories
image

EE
Build1
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40742/6b4ec78fd51fc9ada05f9e1214e26955/Functional/allure-report-ee/index.html#categories
image

Build2
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40742/acaa1d6ca430374f64f558c5e71d73a1/Functional/allure-report-ee/index.html
image

B2B
Build1
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40742/d8f9425cf3020e8b211c65c81d0b19a7/Functional/allure-report-b2b/index.html
image

Build2
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40742/bbc4e08c488d51c059437ce00d7dea08/Functional/allure-report-b2b/index.html
image

WebAPI
Build 1
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40742/70baa3fcb5580b87b335e60466f343ee/Integration/console-error-logs.html
image

Build2
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40742/7d3eeccf53af3a01f682888b138f1004/WebApi/console-error-logs.html
image

Known Issue
TextInlineWidgetEditingSpecialCharacterTest - https://jira.corp.adobe.com/browse/ACQE-9803
https://jira.corp.adobe.com/browse/AC-17120 webpai failure ticket

@engcom-Dash engcom-Dash moved this from Extended testing (optional) to Merge in Progress in Community Dashboard May 12, 2026
@magento-devops-reposync-svc
magento-devops-reposync-svc merged commit 18d09bd into magento:2.4-develop May 20, 2026
8 of 12 checks passed
@ct-prd-projects-boards-automation ct-prd-projects-boards-automation Bot moved this from Merge in Progress to Recently Merged in Community Dashboard May 20, 2026
@mtytula
mtytula deleted the fix/graphql-page-size-limit branch May 21, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P3 May be fixed according to the position in the backlog. Progress: testing in progress Project: Community Picked PRs upvoted by the community

Projects

Status: Recently Merged

Development

Successfully merging this pull request may close these issues.

[Issue] [Bug] GraphQL SearchCriteriaValidator not loaded — removed by module-graph-ql di.xml array override

6 participants