Closed raman-m closed 4 months ago
Route path template placeholders and their validation rules
Special thanks to Guillaume Gnaegi and Fabrizio Mancin!
The bug is related to the Placeholders feature in Configuration and Routing. The bug was introduced in version 23.2.0 as a part of PR #1927.
The new validation rules of the FileConfigurationFluentValidator
class do not allow the Ocelot app to start when implicit placeholders are defined in custom implementations, such as middlewares, delegating handlers, and replaced services in the dependency injection (DI) container.
These new rules are capable of validating explicit placeholders only within the UpstreamPathTemplate
and DownstreamPathTemplate
properties. Unfortunately, they cannot oversee implicit placeholders in custom implementations, and they do not validate early during the Ocelot app startup process.
Ensure that you avoid using version 23.2.0. If you are currently on that version, upgrade to version 23.2.2-beta0001 by applying this hotfix patch.
With version 23.2.0, particularly if you have overridden certain service classes or implemented custom logic that manipulates placeholders, you may encounter Ocelot app crashes accompanied by the following errors in the log:
One or more errors occurred. (Unable to start Ocelot, errors are: XXX)
where XXX
are the following validation error messages:
UpstreamPathTemplate 'UUU' doesn't contain the same placeholders in DownstreamPathTemplate 'DDD'
DownstreamPathTemplate 'DDD' doesn't contain the same placeholders in UpstreamPathTemplate 'UUU'
Finally, the validation rules resulted from the incorrect assumption that placeholders are always explicit and can be validated early. Therefore, custom implementations and feature services in the dependency injection (DI) container, which rely on or manipulate placeholders, should validate the configuration JSON and appropriate options later, directly within their service implementations.
2ded8726 by Raman Maksimchuk on Friday, April 05 at 15:13 → Release 23.2.1-2 artifacts | +semver: patch 14c6d82b by Raman Maksimchuk on Friday, April 05 at 12:57 →
d1855cb9 by Raman Maksimchuk on Thursday, April 04 at 00:17 →
Fixes #2031
2031
Follow up
683
1927
Proposed Changes
IsUpstreamPlaceholderDefinedInDownstream
andIsDownstreamPlaceholderDefinedInUpstream
ServiceFabricPlaceholdersInServiceName
rule