Problem/Motivation

When saving a text format that is not configured to utilize the markdown filter, there is a validation error occurring prevent the configuration form to be saved.

Steps to reproduce

Drupal core 10.3.2
Markdown 3.0.1

  • Go to /admin/config/development/logging
  • Configure and save error display option, e.g. Errors and warnings
  • Install and configure Markdown
  • Create new or edit existing text format
  • Do not enable markdown filter
  • Click Save
  • Observe error message, "'vertical_tabs' is not a supported key."
  • Uninstall Markdown module
  • Create new or edit existing text format
  • Do not enable markdown filter
  • Click Save
  • Observe no error message

Proposed resolution

TBD

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Issue fork markdown-3470570

Command icon 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

jasonawant created an issue. See original summary.

jasonawant’s picture

I think this particular error is a result of config schema validation by Durpal core's ValidKeysConstraint, see change record https://www.drupal.org/node/3324853

I think the solution to this issue could be along the lines of the following:

1. Refine the Markdown filter plugin form and configuration to remove vertical_tabs from the saved form_state
I think when saving the filter without Markdown enabled, vertical_tabs is left in the form_state and it is being saved with the markdown filter settings; however, vertical_tabs is not a key defined with the filter_settings.markdown schema.

2. Further define the schema for the markdown filter settings

Here's how Drupal core's filter_html schema is defined here

filter_settings.filter_html:
  type: mapping
  label: 'Filter HTML'
  mapping:
    allowed_html:
      type: string
      label: 'Allowed HTML'
    filter_html_help:
      type: boolean
      label: 'HTML help'
    filter_html_nofollow:
      type: boolean
      label: 'HTML nofollow'

Compared to the markdown filter schema here

# Filter settings.
filter_settings.markdown:
  type: markdown.parser
  mapping:
    override:
      type: boolean
      label: 'Override'
d0t15t’s picture

This patch prevents that `vertical_tabs` is added to the form state when the Markdown-filter is not enabled, which only addresses the first issue that @jasonawant suggests, but it's enough to prevent the error.

jitendrapurohit’s picture

StatusFileSize
new590 bytes

I was still getting errors like

'error' is not a supported key.
'parser' is not a supported key.

Fixed by the patch attached.

jitendrapurohit’s picture

StatusFileSize
new590 bytes

malcomio made their first commit to this issue’s fork.

malcomio’s picture

Status: Active » Needs review

Setting to "needs review", given that there are patches attached.

Have created a merge request based on the combination of the patches, although I'm not entirely convinced by the return statements inside the catch blocks.

I haven't been able to reproduce this, but wanted to see if this would address #3463119: Error when saving text format - configuration property id doesn't exist.

megachriz made their first commit to this issue’s fork.

megachriz’s picture

I experience this issue when I haven't any markdown libraries installed. When I have the library "league/commonmark:^1.6" installed, I experience #3463119: Error when saving text format - configuration property id doesn't exist instead.

I've implemented a different approach in 3470570-remove-non-config-keys-from-form-state, because I'm not sure if it is correct that ParserConfigurationForm should be assumed to only be used in Filter form context. So instead, I tried to fix it within the FilterMarkdown class.

Also added test coverage that originally was meant for #3463119: Error when saving text format - configuration property id doesn't exist, but that test passes with the provided fix here as long as "league/commonmark" is not installed, apparently.