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 {0} 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.
- Released in version: 23.2.0
- Introduced in: PR #1927
- Reported bug: #2031 by @ggnaegi and tested by @Fabman08
- Hotfix PR: #2032 by @raman-m