DefaultRelativeUrlPropSource does not sort properties keys for comparison

Created on 3 October 2025, 4 months ago
Updated 22 October 2025, 3 months ago

Overview

When using a code component with a prop of image or video you cannot publish a page using the default prop values. If you do, you get:

Error 500: Extraneous JSON Schema information detected: { "properties": { "src": { "type": "string", "format": "uri-reference", "pattern": "^(\/|https?:\/\/)?(?!.*\\:\/\/)[^\\s]+$", "contentMediaType": "video\/*" }, "poster": { "type": "string", "format": "uri-reference", "pattern": "^(\/|https?:\/\/)?(?!.*\\:\/\/)[^\\s]+$", "contentMediaType": "image\/*" } }, "required": [ "src" ], "type": "object" }  should have been just { "properties": { "src": { "type": "string", "contentMediaType": "video\/*", "format": "uri-reference", "pattern": "^(\/|https?:\/\/)?(?!.*\\:\/\/)[^\\s]+$" }, "poster": { "type": "string", "contentMediaType": "image\/*", "format": "uri-reference", "pattern": "^(\/|https?:\/\/)?(?!.*\\:\/\/)[^\\s]+$" } }, "required": [ "src" ], "type": "object" }.

That's because the comparison logic doesn't sort recursively through the JSON schema.

    ksort($sdc_prop_source['jsonSchema']);
    ksort($minimal);
    if ($sdc_prop_source['jsonSchema'] !== $minimal) {

The properties keys are not sorted the same.

Proposed resolution

Drupal doesn't have a recursive ksort, so hack it like

    ksort($sdc_prop_source['jsonSchema']);
    foreach (array_keys($sdc_prop_source['jsonSchema']['properties']) as $property_key) {
      ksort($sdc_prop_source['jsonSchema']['properties'][$property_key]);
    }
    ksort($minimal);
    foreach (array_keys($minimal['properties']) as $property_key) {
      ksort($minimal['properties'][$property_key]);
    }

User interface changes

🐛 Bug report
Status

RTBC

Version

1.0

Component

… to be triaged

Created by

🇺🇸United States mglaman WI, USA

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024