dotnet / dotnet/runtime

[API Proposal]: Provide full path to the configuration section when validation fails.

Open
#121,378 3 comments 0 reactions 0 assignees View on GitHub
area-Extensions-Options
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Background and motivation

It's possible to enable valiadtion of options class bound to the configuration.
When validation fails, the exception is thrown:
> Microsoft.Extensions.Options.OptionsValidationException: 'DataAnnotation validation failed for 'Options' members: 'InvitationClientId' with the error: ...

This is nice, but could be be better.

### API Proposal

I suggest adding the path to the configuration section:
> Microsoft.Extensions.Options.OptionsValidationException: 'DataAnnotation validation failed for 'Options' (bound to 'Identity:Integrations:Auth0' config section) members: 'InvitationClientId' with the error: ...

This will greatly improvde DX.

### API Usage

Unless we want disclosure of configuration section configurable, there's no change in public api.

### Alternative Designs

_No response_

### Risks

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.