Skip to content

[Versioned Clients][API Notifications] Fails to read new versions when available #1070

Closed
@chamweer

Description

@chamweer

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

As described in API Notifications section, the default ApiVersionHandlerLogger<ApiVersionHandler> is expected to log an Information message when a new version is available; however, the ApiVersionParser fails to parse the api-supported-versions header's comma separated values generated by the DefaultApiVersionReporter and as a result no new version will be reported.

The problem here is that the client side's ApiVersionEnumerator expects the version values to be in multiple header keys (Headers: .... [api-supported-versions, 0.9], [api-supported-versions, 1.0] ...) whereas the header, generated through DefaultApiVersionReporter in the server application, contains all supported versions in a single header (Headers: .... [api-supported-versions, 0.9, 1.0] ...).

The following is a sample response generated for a GET request:

❯ curl http://localhost:5282/api/v0.9/products/

StatusCode        : 200
StatusDescription : OK
Content           : .....
RawContent        : HTTP/1.1 200 OK
                    Transfer-Encoding: chunked
                    api-supported-versions: 0.9, 1.0
                    api-deprecated-versions: 0.8
                    Sunset: Mon, 31 Mar 2025 23:00:00 GMT
                    Link: <https://docs.api.com/policy.html?api-version=...
Forms             : {}
Headers           : {[Transfer-Encoding, chunked], [api-supported-versions, 0.9, 1.0], [api-deprecated-versions, 0.8], [Sunset, Mon, 31 Mar 2025 23:00:00 GMT]...}
...

Expected Behavior

New version details should be notified by default through the logger when available.

Steps To Reproduce

Sample Repo to reproduce the issue: https://github.com/chamweer/api-version-notification-bug

This repository contains 3 versioned endpoints representing 3 different use cases:

  • V0.8: Deprecated
  • V0.9: Live and sunset policy is set.
  • V1.0: New version.

Steps to reproduce the issue:

  1. Start the Api.Versioning.Notification.Bug.Api project using dotnet run command.
  2. Run the Api.Versioning.Notification.Bug.Client console app and monitor the logs to see whether you can see any information logs reporting the available versions.

Exceptions (if any)

.NET Version

8.0.101

Anything else?

Asp.Versioning.Http.Client 8.0.0

Console Logs:

info: System.Net.Http.HttpClient.V0.8Client.LogicalHandler[100]
      Start processing HTTP request GET http://localhost:5128/api/v%7Bversion%7D/products
info: System.Net.Http.HttpClient.V0.8Client.ClientHandler[100]
      Sending HTTP request GET http://localhost:5128/api/v0.8/products
info: System.Net.Http.HttpClient.V0.8Client.ClientHandler[101]
      Received HTTP response headers after 87.3609ms - 200
warn: Asp.Versioning.Http.ApiVersionHandler[1]
      API version 0.8 for http://localhost:5128/api/v0.8/products has been deprecated and will sunset on <unspecified>. Additional information:
info: System.Net.Http.HttpClient.V0.8Client.LogicalHandler[101]
      End processing HTTP request after 133.8124ms - 200
info: System.Net.Http.HttpClient.V0.9Client.LogicalHandler[100]
      Start processing HTTP request GET http://localhost:5128/api/v%7Bversion%7D/products
info: System.Net.Http.HttpClient.V0.9Client.ClientHandler[100]
      Sending HTTP request GET http://localhost:5128/api/v0.9/products
info: System.Net.Http.HttpClient.V0.9Client.ClientHandler[101]
      Received HTTP response headers after 27.1239ms - 200
info: System.Net.Http.HttpClient.V0.9Client.LogicalHandler[101]
      End processing HTTP request after 40.1566ms - 200
info: System.Net.Http.HttpClient.V1Client.LogicalHandler[100]
      Start processing HTTP request GET http://localhost:5128/api/v%7Bversion%7D/products
info: System.Net.Http.HttpClient.V1Client.ClientHandler[100]
      Sending HTTP request GET http://localhost:5128/api/v1.0/products
info: System.Net.Http.HttpClient.V1Client.ClientHandler[101]
      Received HTTP response headers after 5.5906ms - 200
info: System.Net.Http.HttpClient.V1Client.LogicalHandler[101]
      End processing HTTP request after 9.453ms - 200

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions