Repository navigation
Enable client redirects in the Swagger client template - #17625
Merged
Merged
Conversation
The generated clients only accept 2xx, so an endpoint that answers with a redirect to storage instead of the content fails. Fetching Helix console output reports "The response contained an invalid status code 302 Found". This was fixed once in dotnet#15599, but the change was made in generated-code/HelixApi.cs. Regenerating that file removed it, and it is absent from current main and from every shipped Microsoft.DotNet.Helix.Client package, so the bug came back unnoticed. Fix it in ServiceClient.hb so it survives regeneration and applies to every generated client, and regenerate the affected Helix output so it takes effect without waiting for an unrelated regeneration. Azure.Core drops the Authorization header when a redirect crosses to another host, so the service token is not sent to the redirect target. That is why fetching the same URL with curl -L already worked. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues were identified that would block approval.
Review effort: Lite
Findings: None
What changed in this PR
Updates the Swagger C# client template to follow storage redirects and regenerates the Helix client accordingly.
Changes:
- Enables
HttpPipelineTransportOptions.IsClientRedirectEnabled. - Applies the fix to generated clients and refreshed Helix output.
| File | Description |
|---|---|
| src/Microsoft.DotNet.SwaggerGenerator/Microsoft.DotNet.SwaggerGenerator.CodeGenerator/Languages/csharp/ServiceClient.hb | Updated as part of this pull request. |
| src/Microsoft.DotNet.Helix/Client/CSharp/generated-code/HelixApi.cs | Updated as part of this pull request. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mmitche
approved these changes
Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated clients only accept 2xx, so an endpoint that answers with a redirect to storage instead of the content fails. Fetching Helix console output reports:
Why this is back
This was fixed once in #15599, but that change was made in
generated-code/HelixApi.cs. Regenerating that file removed it. The argument is absent from currentmain:and from every shipped
Microsoft.DotNet.Helix.Clientpackage I checked (10.0.0-beta.26468.2,11.0.0-beta.26425.1,12.0.0-beta.26475.4— none containHttpPipelineTransportOptions). So the bug returned silently after #15599 shipped.This change
ServiceClient.hbso it survives regeneration and applies to every generated client, not just Helix.Security note
Azure.Core drops the
Authorizationheader when a redirect crosses to another host, so the service token is not sent to the redirect target. That is why fetching the same URL withcurl -Lalready worked, and why #15599 hit a 403 when it tried replaying the request manually with the original header.Validation
Verified the equivalent fix end to end by supplying a redirect-following transport from a caller and running
osob-cli execagainst a live queue: console output is returned instead of the exception.