diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 422d18621..48db3c3bf 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,4 +1,31 @@ -## Documentation patch (version {0}) for [{1}](https://github.com/ThreeMammals/Ocelot/releases/tag/{1}) release -> Read the Docs: [Ocelot 23.2](https://ocelot.readthedocs.io/en/{0}/) +## Hotfix release (version {0}) for #2031 issue +> Route path template placeholders and their validation rules -This is a technical release: no other information. +Special thanks to **[Guillaume Gnaegi](https://github.com/ggnaegi)** and [Fabrizio Mancin](https://github.com/Fabman08)! + +### About +The bug is related to the [Placeholders](https://ocelot.readthedocs.io/en/latest/features/routing.html#placeholders) feature in [Configuration](https://ocelot.readthedocs.io/en/latest/features/configuration.html) and [Routing](https://ocelot.readthedocs.io/en/latest/features/routing.html). +The bug was introduced in version [23.2.0](https://github.com/ThreeMammals/Ocelot/releases/tag/23.2.0) as a part of PR #1927. + +### Breaking Change +The new [validation rules](https://github.com/ThreeMammals/Ocelot/blob/23.2.0/src/Ocelot/Configuration/Validator/FileConfigurationFluentValidator.cs#L45-L50) of the `FileConfigurationFluentValidator` class do not allow the Ocelot app to start when implicit [placeholders](https://ocelot.readthedocs.io/en/latest/features/routing.html#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](https://ocelot.readthedocs.io/en/latest/features/routing.html#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](https://github.com/ThreeMammals/Ocelot/releases/tag/23.2.0). If you are currently on that version, upgrade to version [{0}](https://github.com/ThreeMammals/Ocelot/releases/tag/{0}) by applying this hotfix patch. + +### Technical info +With version [23.2.0](https://github.com/ThreeMammals/Ocelot/releases/tag/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](https://github.com/ThreeMammals/Ocelot/blob/23.2.0/src/Ocelot/Configuration/Validator/FileConfigurationFluentValidator.cs#L45-L50) 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 +- Released in version: [23.2.0](https://github.com/ThreeMammals/Ocelot/releases/tag/23.2.0) +- Introduced in: PR #1927 +- Reported bug: #2031 by @ggnaegi and tested by @Fabman08 +- Hotfix PR: #2032 by @raman-m diff --git a/build.cake b/build.cake index 680d2c0bf..f7896932f 100644 --- a/build.cake +++ b/build.cake @@ -56,7 +56,7 @@ var nugetFeedStableSymbolsUploadUrl = "https://www.nuget.org/api/v2/package"; string committedVersion = "0.0.0-dev"; GitVersion versioning = null; int releaseId = 0; -bool IsTechnicalRelease = true; +bool IsTechnicalRelease = false; string gitHubUsername = "TomPallister"; string gitHubPassword = Environment.GetEnvironmentVariable("OCELOT_GITHUB_API_KEY"); @@ -84,7 +84,7 @@ Task("RunTests") .IsDependentOn("RunIntegrationTests"); Task("Release") - //.IsDependentOn("Build") + .IsDependentOn("Build") .IsDependentOn("CreateReleaseNotes") .IsDependentOn("CreateArtifacts") .IsDependentOn("PublishGitHubRelease") @@ -306,11 +306,11 @@ Task("CreateReleaseNotes") } } // END of Top 3 - releaseNotes.Add("### Honoring :medal_sports: aka Top Contributors :clap:"); - releaseNotes.AddRange(topContributors); - releaseNotes.Add(""); - releaseNotes.Add("### Starring :star: aka Release Influencers :bowtie:"); - releaseNotes.AddRange(starring); + // releaseNotes.Add("### Honoring :medal_sports: aka Top Contributors :clap:"); + // releaseNotes.AddRange(topContributors); + // releaseNotes.Add(""); + // releaseNotes.Add("### Starring :star: aka Release Influencers :bowtie:"); + // releaseNotes.AddRange(starring); releaseNotes.Add(""); releaseNotes.Add($"### Features in Release {releaseVersion}"); var commitsHistory = GitHelper($"log --no-merges --date=format:\"%A, %B %d at %H:%M\" --pretty=format:\"%h by **%aN** on %ad →%n%s\" {lastRelease}..HEAD"); @@ -423,7 +423,7 @@ Task("RunIntegrationTests") Task("CreateArtifacts") .IsDependentOn("CreateReleaseNotes") - //.IsDependentOn("Compile") + .IsDependentOn("Compile") .Does(() => { WriteReleaseNotes(); @@ -530,7 +530,6 @@ Task("PublishToNuget") if (IsRunningOnCircleCI()) { - Information("Publish to NuGet..."); PublishPackages(packagesDir, artifactsFile, nugetFeedStableKey, nugetFeedStableUploadUrl, nugetFeedStableSymbolsUploadUrl); } }); @@ -588,7 +587,7 @@ private void PersistVersion(string committedVersion, string newVersion) /// Publishes code and symbols packages to nuget feed, based on contents of artifacts file private void PublishPackages(ConvertableDirectoryPath packagesDir, ConvertableFilePath artifactsFile, string feedApiKey, string codeFeedUrl, string symbolFeedUrl) { - Information("PublishPackages"); + Information("Publishing to NuGet..."); var artifacts = System.IO.File .ReadAllLines(artifactsFile) .Distinct(); @@ -601,17 +600,13 @@ private void PublishPackages(ConvertableDirectoryPath packagesDir, ConvertableFi } var codePackage = packagesDir + File(artifact); + Information("Pushing package " + codePackage + "..."); - Information("Pushing package " + codePackage); - - Information("Calling NuGetPush"); - + Information("Calling DotNetNuGetPush"); DotNetNuGetPush( codePackage, - new DotNetNuGetPushSettings { - ApiKey = feedApiKey, - Source = codeFeedUrl - }); + new DotNetNuGetPushSettings { ApiKey = feedApiKey, Source = codeFeedUrl } + ); } } diff --git a/docs/features/configuration.rst b/docs/features/configuration.rst index b6e6bd2ef..552767f49 100644 --- a/docs/features/configuration.rst +++ b/docs/features/configuration.rst @@ -189,10 +189,10 @@ For example: .. code-block:: csharp - ConfigureAppConfiguration((hostingContext, config) => + ConfigureAppConfiguration((context, config) => { config.AddJsonFile(ConfigurationBuilderExtensions.PrimaryConfigFile, optional: false, reloadOnChange: true); // old approach - var env = hostingContext.HostingEnvironment; + var env = context.HostingEnvironment; var mergeTo = MergeOcelotJson.ToFile; // ToMemory var folder = "/My/folder"; FileConfiguration configuration = new(); // read from anywhere and initialize