Repository navigation
Suggest the closest storage key for unknown fields in bs_validate_block() - #198
Merged
dnnsjsk merged 1 commit intoNov 4, 2026
Merged
Conversation
…ck() An unknown_field finding listed every known key in expected but gave no hint which one was meant, while unknown settings and the PHPStan rules already say "did you mean". The message now names the closest key at the same level within three edits, the rule Settings::closest_key() uses. The finding keeps its six keys; expected is unchanged.
Contributor
|
Merged and released in 7.7.12, included in ff1b433. Unknown stored fields now suggest the closest key at the same storage level without changing stored values or the machine-readable finding format. Added regression coverage for prefixed groups, nested repeaters, extensions, bounded matching, and CLI output, plus docs and translations. Full CI and distribution checks passed. Thanks for the contribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An
unknown_fieldfinding lists every known storage key inexpected, but its message does not say which one was probably meant. Unknown settings (Settings::closest_key()) and the PHPStan rules for attribute access, block.json and field.json already add "did you mean", so tooling aroundbs_validate_block()currently computes the same suggestion itself.This adds the closest key at the same level to the message, within three edits and case-insensitive, the rule
Settings::closest_key()uses:expectedstill lists every known key, so tooling that readscodeandexpectedsees no change.rows/0/titelsuggeststitle).Did you mean "%s"?in the POT and in the de_DE and de_DE_formal translations; the other locales are left to the translation run, as with Report unknown top-level attributes in bs_validate_block() #194.docs/blocks/rendering.md(and the same lines inblockstudio-llm-full.txt).test_unknown_field_message_names_the_closest_key_at_its_level(typo, case, repeater row, no close key).Checked locally:
composer csand PHPStan on the validator,npm run docs:check, and a WordPress Playground run with this branch as the plugin, wherebs_validate_block()reportsDid you mean "titel"?fortiltein English and German and no suggestion for a key with nothing close. The PHP unit suite needs wp-env, so it runs in CI here.