[http-client-csharp] Fix trailing path separator for optional path parameter#11096
Merged
JoshLove-msft merged 5 commits intoJun 29, 2026
Merged
Conversation
When a route ends with an optional path parameter (e.g.
/items/{name}/{version} with optional version), the separator '/'
preceding the optional segment was emitted unconditionally, producing
/items/{name}/ when the value was null instead of /items/{name}.
Defer the trailing separator into the parameter's null check so it is
only written when the optional value is present.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
commit: |
Contributor
|
No changes needing a change description found. |
|
You can try these changes here
|
jorgerangel-msft
approved these changes
Jun 29, 2026
So the @next dependency bump (typespec-bump-deps) upgrades spec-api alongside http-specs/spector. As a transitive-only dep it was pinned at alpha.14, which lacks the match.string matcher used by newer http-specs specs (e.g. encode/boolean), breaking the Spector test server. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The 'az webapp config container set' step can fail with a transient GatewayTimeout from Microsoft.Web even though the ACR image build/push succeeded. Wrap it in a retry loop with backoff; the command is idempotent so re-issuing is safe. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jsquire
approved these changes
Jun 29, 2026
timotheeguerin
approved these changes
Jun 29, 2026
'az webapp config container set' consistently returns a GatewayTimeout from Microsoft.Web even though the ARM update is applied server-side, so blind retries keep failing. Issue the set (tolerating the timeout) and poll 'az webapp config container show' to confirm the new image tag was applied, only treating the deploy as failed if verification never succeeds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jsquire
approved these changes
Jun 29, 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.
Problem
When a route ends with an optional path parameter, the
/separator preceding that segment was emitted unconditionally, leaving a dangling trailing slash when the value is null.For example,
/certificates/{certificate-name}/{certificate-version}(withcertificate-versionoptional) generated:So when
certificateVersionis null the wire URL becomes/certificates/{name}/instead of/certificates/{name}. Services (e.g. Key Vault) and recorded test cassettes expect no trailing slash.The existing
shouldPrependWithPathSeparatorlogic only handled the case where the preceding literal does not end in/; it missed the case where the separator had already been written unconditionally.Fix
In
RestClientProvider.AddUriSegments, when the upcoming path parameter is optional and the preceding literal ends with/, defer that trailing/so it is written together with the parameter value inside the null check:Required path parameters are unaffected.
Tests
TestBuildCreateRequestMethodWithOptionalPathParameter(+ golden file) covering the trailing optional-segment case.ServerTemplate*tests that relied on the test factory's defaultisRequired: falsefor what were intended to be normal required path parameters.Microsoft.TypeSpec.Generator.ClientModelsuite passes (1440 tests).Reported in Azure/azure-sdk-for-net#60162 (Bug A).
--generated by Copilot