You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The wiki for versioning policies explicitly states that
Sunset policies do not have to have a date. The following scenarios are supported:
-Define a sunset policy by API name and version
-Define a sunset policy by API name for any version
-Define a sunset policy by API version for any API
Based on the last item in that list, I assumed that I should be able to create a sunset policy for a specific API version, regardless of the API name, so this is what I did:
I can confirm that the above works well because responses for API v3 now include Sunset Mon, 01 Jan 2025 00:00:00 GMT HTTP header.
However, when trying to access the sunset policy from the ApiExplorer APIs (i.e. bestMatch.Properties.TryGetValue(typeof(SunsetPolicy))) it returns null
Digging into the code for VersionedApiDescriptionProvider, I noticed that it uses ISunsetPolicyManagerExtensions.TryResolvePolicy to try to obtain the SunsetPolicy based on the API name and version and that method is returning null in my scenario. The reason it returns null is because it tries to find the policy using name AND version and, as shown above, my sunset policies do not have a name associated with them - they should apply to any API name as described on the wiki.
Notice that this behavior is different than what DefaultApiVersionReporter does. That class, who is responsible for writing the Sunset HTTP response header, uses a different strategy to obtain the SunsetPolicy for a given API name and version: first it tries to get a policy based on the name AND version provided, if it can't find one then it tries to find a policy based on the name only, if it still can't find a policy it then tries to find a policy based on the version only.
My assumption is that VersionedApiDescriptionProvider should use the same strategy as DefaultApiVersionReporter to find a suitable SunsetPolicy.
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered:
Strange... I guess I added the new function, but didn't refactor it or somehow forgot. It seems TryResolvePolicy still has the same logic, but after a closer inspection, I repro'd the issue. The cause appears to be here:
It should be a new if statement rather than else if. This causes it to not fallback when it should. I can also see this wasn't caught because the test case is setup incorrectly:
Is there an existing issue for this?
Describe the bug
The wiki for versioning policies explicitly states that
Based on the last item in that list, I assumed that I should be able to create a sunset policy for a specific API version, regardless of the API name, so this is what I did:
I can confirm that the above works well because responses for API v3 now include
Sunset Mon, 01 Jan 2025 00:00:00 GMT
HTTP header.However, when trying to access the sunset policy from the ApiExplorer APIs (i.e.
bestMatch.Properties.TryGetValue(typeof(SunsetPolicy))
) it returnsnull
Digging into the code for
VersionedApiDescriptionProvider
, I noticed that it usesISunsetPolicyManagerExtensions.TryResolvePolicy
to try to obtain theSunsetPolicy
based on the API name and version and that method is returningnull
in my scenario. The reason it returnsnull
is because it tries to find the policy using name AND version and, as shown above, my sunset policies do not have a name associated with them - they should apply to any API name as described on the wiki.Notice that this behavior is different than what
DefaultApiVersionReporter
does. That class, who is responsible for writing the Sunset HTTP response header, uses a different strategy to obtain theSunsetPolicy
for a given API name and version: first it tries to get a policy based on the name AND version provided, if it can't find one then it tries to find a policy based on the name only, if it still can't find a policy it then tries to find a policy based on the version only.My assumption is that
VersionedApiDescriptionProvider
should use the same strategy asDefaultApiVersionReporter
to find a suitableSunsetPolicy
.Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: