Problem/Motivation
Unconditional render-time JSON Schema validation in PatternFieldProcessorPluginManager::processSchemaValues must be removed. It regresses behavior relative to Patternkit 9.1.2: sites that upgrade can see visitor-visible "This content is unavailable." for blocks whose stored configuration fails JSON Schema checks (for example required or minLength) even though 9.1.2 still rendered those blocks. Separately, token values in format-constrained fields may produce WARNING-level log noise on render in some configurations, but that scenario is harder to reproduce when server-side preprocessing already bypasses format validation for tokens.
This behavior was introduced on the 9.1.x branch after the 9.1.2 release via #3563760: Add Pattern Content Validation During Rendering (merge request and commit history on that issue). The intent—extra safeguards during rendering—is sound, but the current implementation runs two validation passes on every render without configuration or stamp-based gating, which is incompatible with real content that 9.1.2 already served and with gradual upgrade expectations.
Relationship to #3563760: This issue documents why that render-path change needs to be reverted for the next stable release line, while keeping the validation helper infrastructure (assertValidPatternContent, PatternValidationHelper, and associated tests) so a follow-up, stamp-aware render policy can use it without reintroducing the same upgrade break.
Steps to reproduce
The patternkit_test module included in this MR provides a dedicated Render validation test component that covers each constraint class the regression affects. This is the recommended reproduction path, as it requires no schema modification.
Setup (required once):
- Apply MR !187 (or check out the branch
3583333-revert-render-time-validationand temporarily revert it to reproduce the regression). - Add the following to
settings.phpso Drupal's extension discovery scanstests/modules/:
$settings['extension_discovery_scan_tests'] = TRUE; - Enable the test module:
drush en patternkit_test
Reproducing the WARNING regression (Email, Hostname, Date/Time fields):
- Place a Render validation test block in Layout Builder.
- Enter a Drupal token in the Email field (e.g.
[user:mail]) and save. - Clear caches (
drush cr) to force a cache-miss render and load the page. - With the regression present:
WARNING-level log entries appear in/admin/reports/dblogfor that block's pattern ID on every cache-miss render. - With this MR applied: No
WARNINGis logged. The block renders normally.
Reproducing the "content unavailable" regression (type mismatch):
- Use
drush pksetto inject a non-string value (e.g. integer42) into the Label field of a Render validation test block instance, bypassing the editor form. - Clear caches and load the page.
- With the regression present: "This content is unavailable." renders instead of the block output.
- With this MR applied: The block renders without error.
Note: Reproducing the 9.1.2 baseline on Drupal 11 using the Patternkit 9.1.2 tag may require applying the Drupal 11 compatibility fix from commit 01abf92 first. Without it, Drush and full bootstrap can terminate with a fatal error: LayoutHelper and LayoutEntityHelperTrait define the same property ($sectionStorageManager) with incompatible definitions.
Proposed resolution
Revert the two assertValidPatternContent calls from the render path inside processSchemaValues—specifically, remove the pre-traverseSchema call (soft validation / logging) and the post-traverseSchema call (strict validation / exception). Field processor traversal and existing SchemaException handling remain unchanged.
In scope
- Restore 9.1.2-equivalent render-time behavior for pattern block value processing (no JSON Schema value validation inside
processSchemaValueson each render). - Retain
assertValidPatternContent,PatternValidationHelper, and unit coverage for them for use by future work. - Expand automated tests to verify the 9.1.2-parity contract across all relevant constraint classes: unit and kernel tests for
processSchemaValuesnow use data providers covering a plain string type, all four swaggest-validatedformatkeywords (uri,email,hostname,date-time), and a regexpatternconstraint. A dedicatedrender_validation_testcomponent inpatternkit_testprovides one field per constraint type for both automated and manual verification.
Out of scope
- Implementing replacement stamp-aware or tiered render-time validation (planned as a separate follow-up issue and release target).
- Save-time enforcement toggles, token-format bypass at save time, or stamp table work—those are parallel tracks and must not be conflated with this revert.
Path forward after this revert: Reintroduce render-time validation only behind an explicit policy (for example validity stamps and schema fingerprinting) so upgrades from 9.1.2 do not suddenly fail or flood logs for previously accepted content. That follow-up should reference this issue and #3563760 for historical context.
Remaining tasks
- Peer review and RTBC. MR !187 is open against
9.1.x; CI is green on PHP 8.1 and PHP 8.3. - After merge, add a short comment on #3563760 linking this issue and the merge request, summarizing the regression and pointing readers at the planned stamp-aware follow-up (separate issue).
User interface changes
None. Restores prior rendering behavior for affected blocks; administrators may see fewer log warnings and fewer "content unavailable" fallbacks after upgrade.
Introduced terminology
None.
API changes
None. processSchemaValues stops performing render-time content validation; callers and signatures are unchanged. Validation helpers remain available for other code paths and future policy work.
Data model changes
None.
Release notes snippet
Removed unconditional JSON Schema validation from the pattern render path (PatternFieldProcessorPluginManager::processSchemaValues) to match Patternkit 9.1.2 behavior and avoid upgrade-time log noise and unintended "content unavailable" fallbacks. See related issue #3563760 for the original render-time validation change and this issue for the revert rationale.
Issue fork patternkit-3583333
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
sluceroThe MR implements the targeted code reverts and maintains the assert functions for future usage when render-time validation is reintroduced. The MR is now ready for review.
Comment #4
sluceroAdded a
render_validation_testcomponent to thepatternkit_testmodule in this MR to make the regression scenarios in this issue concrete and reproducible for both automated tests and manual verification.What was added. The component provides one field per constraint type that the regression affected. Each field is independently testable, so a failure during review or QE points directly at the constraint class that broke:
type: string) — Inject a non-string value (e.g. integer) viadrush pksetto verify that schema-invalid stored content renders without throwing aSchemaValidationExceptionor displaying "This content is unavailable."format: uri) — Token bypass is supported server-side viaTokenValidationDataPreProcessor, which nulls theuriformat constraint when a token is detected. A[node:url]value must render without a WARNING.format: email) — Token in a format-constrained field with no server-side bypass. This is the primary regression path: storing[user:mail]in this field produced a WARNING log entry on every cache-miss render when the regression was present.format: hostname) — Same regression class as Email. No bypass exists forhostnameformat; a token value must render without a WARNING.format: date-time) — Same regression class. Token values must render without a WARNING.patternregex) — Documents a known limitation: Drupal tokens do not satisfy strict ISO 8601 regex patterns and no bypass equivalent toformat: uriexists. Tokens entered here fail client-side AJV validation and cannot be saved through the editor. This boundary is unchanged and is not a regression.How to enable the test module. The
patternkit_testmodule lives undertests/modules/. Drupal skipstests/subdirectories during extension discovery by default. Add the following tosettings.phpto make the module visible on the Extend page:Then enable the module:
Once enabled, Render validation test appears in the pattern library and can be added as a block through Layout Builder.
Verifying the regression is fixed. For each format-constrained field (Email, Hostname, Date/Time):
[user:mail]in Email).drush cr) to force a cache-miss render./admin/reports/dblog). With the regression present, a WARNING is logged for that block's pattern ID on every cache-miss. With this MR applied, no WARNING appears and the block renders normally.For the type-mismatch scenario, use
drush pksetto inject a non-string value (e.g. integer42) directly into stored block data, bypassing the editor form. The block must still render rather than displaying "This content is unavailable."Automated test coverage. The unit and kernel tests for
PatternFieldProcessorPluginManager::processSchemaValueswere expanded from single-case assertions to data providers keyed to these six field types. Each case asserts that the stored value passes through unmodified and that no WARNING is logged, covering all constraint classes in one suite.Files changed:
tests/modules/patternkit_test/lib/patternkit_test/components/render_validation_test/render_validation_test.json— New pattern schema with six typed/format-constrained fieldstests/modules/patternkit_test/lib/patternkit_test/components/render_validation_test/render_validation_test.twig— Twig template for the new componenttests/src/Unit/PatternFieldProcessorPluginManagerTest.php— Replaced single-case test with a six-case data provider (providerSchemaInvalidStoredContent)tests/src/Kernel/PatternFieldProcessorPluginManagerTest.php— Replaced single-case test with a six-case data provider (providerRenderValidationTestStoredContent) using the actual pattern fileComment #5
sluceroThis branch now includes a small fixture-parity update to make the
render_validation_testcomponent more complete for verification across format-constrained field types.Specifically, commit
1d54ed8expands the test component schema/template so the fixture covers additional format-bearing and nested-value shapes (ipv4, nestedlink.hrefwithformat: uri, andrich_text_htmlwithformat: html), in addition to the existinguri,email,hostname, anddate-timefields.This does not change the revert scope in this issue. The goal is to reduce branch-to-branch fixture drift and keep manual/automated comparison workflows stable while review and QE continue.
Comment #6
sluceroValidated internally and ready to merge.
Comment #8
sluceroThis has now been merged for inclusion in the 9.1.3 release.
See #3542304: Patternkit 9.1.3 Release Plan.