ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.28k stars 1.63k forks source link

#2031 Don't validate placeholders in templates #2032

Closed raman-m closed 4 months ago

raman-m commented 4 months ago

Fixes #2031

Follow up

Proposed Changes

raman-m commented 4 months ago

Hotfix release (version 23.2.2-beta0001) for #2031 issue

Route path template placeholders and their validation rules

Special thanks to Guillaume Gnaegi and Fabrizio Mancin!

About

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.

Breaking Change

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.

Technical info

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:

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.

Bug Artifacts

Features in Release 23.2.2-beta0001

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 →

2031 Don't validate placeholders in templates (#2032)

d1855cb9 by Raman Maksimchuk on Thursday, April 04 at 00:17 →

1673 #1672 Update Docker for CircleCI builds (#2030)