Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[OptionsResolver] Fix missing prototype key in nested error paths#62344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
yoeunes wants to merge1 commit intosymfony:6.4
base:6.4
Choose a base branch
Loading
fromyoeunes:options-resolver-nested-prototype-path-6.4

Conversation

@yoeunes
Copy link
Contributor

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
Issues-
LicenseMIT

This PR fixes a bug whereMissingOptionsException error messages for nested prototypes generated an incomplete path. When an option was missing inside a prototype that wasitself nested inside another prototype, the key of the parent prototype was omitted from the error message.

The fix ensures the parent's prototype index is correctly tracked and prepended when resolving nested options, providing a full and accurate path for easier debugging.

Example:

Given the following nested prototype setup:

$resolver->setOptions('connections',staticfunction (OptionsResolver$connResolver) {$connResolver->setPrototype(true);// Parent prototype// ...$connResolver->setOptions('replicas',staticfunction (OptionsResolver$replicaResolver) {$replicaResolver->setPrototype(true);// Nested prototype$replicaResolver->setRequired(['host']);    });});

And this configuration, which is missing ahost inmain_db's second replica:

$options = ['connections' => ['main_db' => [// ...'replicas' => [                ['host' =>'replica-01.local'],                [],// Missing 'host' here            ],        ],    ],];$resolver->resolve($options);

Before (The Bug):
The exception message was incorrect, missing themain_db key:
The required option "connections[replicas][1][host]" is missing.

After (The Fix):
The exception message is now correct and includes the full path:
The required option "connections[main_db][replicas][1][host]" is missing.

A test case (testNestedPrototypeErrorPathHasFullContext) has been added to cover this scenario and prevent regressions.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ycerutoycerutoyceruto approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

3 participants

@yoeunes@yceruto@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp