Problem/Motivation

The block visibility condition response_status stores a status_codes list in config, but the schema type condition.plugin.response_status does not declare FullyValidatable and places no constraints on the values inside status_codes. Any integer (or, with no Choice constraint, any value coercible to integer) is currently accepted at the typed-config layer, even though the plugin's form only exposes 200, 403, and 404, and ResponseStatus::evaluate() is hard-coded around those three codes.

Proposed resolution

In core/modules/system/config/schema/system.schema.yml, on condition.plugin.response_status:

  • Add FullyValidatable: ~ at the type level.
  • Add a Choice constraint with choices: [200, 403, 404] on each item of the status_codes sequence, matching the codes built by ResponseStatus::buildConfigurationForm().

Remaining tasks

Reviews.

User interface changes

None. The condition's checkbox form already restricts UI input to the supported codes; this change closes the gap for config that bypasses the form (config import, configuration actions, programmatic edits).

Introduced terminology

API changes

None.

Data model changes

Config schema constraints.

Release notes snippet

N/A

Issue fork drupal-3525392

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

penyaskito created an issue. See original summary.

penyaskito’s picture

Title: Add constraint for ResponseStatus Condition status code so can be FullValidatable » Add constraint for ResponseStatus Condition status code so it can be FullyValidatable
Issue tags: +Configuration schema, +validation
penyaskito’s picture

penyaskito’s picture

Component: system.module » configuration system
irafah’s picture

Assigned: Unassigned » irafah

I will look at this issue.

irafah’s picture

I raised a merge request for this issue. The description doesn't have many details, so I just created a validation to make it fully validated, but let me know if anything else is needed.

The "Lint" tests passed, but there's a "DEFAULT: PHP 8.3 MySQL 8.0" test that failed. It seems to be related to something else, so please advise on how to proceed.

Thank you!

irafah’s picture

Assigned: irafah » Unassigned
Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Seems like something we will need test coverage for.

penyaskito’s picture

This needs defining constraints in the config schema as explicit in the issue summary + tags, not any change to form validation.

rodrigoaguilera’s picture

Issue tags: +Vienna2025

Triaging this I think this still a good issue for novices. For example you can look at following issue for inspiration
#3541535: Make the `field_config_base` structure fully validatable by adding a StringEqualsConcatenatedValuesConstraint

As @penyaskito mentioned is not about form validation but adding constraints. Feel free to open a new branch

The Drupal Contribution Mentoring team is triaging issues for Drupalcon Vienna 2025, and we are reserving this issue for Mentored Contribution during the event.

After October 17th, this issue returns to being open to all. Thanks!

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

penyaskito’s picture

Issue summary: View changes

penyaskito’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

penyaskito’s picture

penyaskito’s picture

Issue summary: View changes
borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Looks great, I don't know what else I'd ask for

  • alexpott committed 65c72ba0 on main
    task: #3525392 Add constraint for ResponseStatus Condition status code...
alexpott’s picture

Version: main » 11.x-dev
Category: Bug report » Task
Status: Reviewed & tested by the community » Fixed

Committed and pushed 65c72ba0665 to main and f17f0cea804 to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed f17f0cea on 11.x
    task: #3525392 Add constraint for ResponseStatus Condition status code...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.