SDK-2806 Fix DigitalIdentityService QR-code URL construction#546
Merged
mehmet-yoti merged 2 commits intoMay 15, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes QR-code endpoint construction in DigitalIdentityService and adds assertions to guard against the regression.
Changes:
- Replaces malformed
string.Format/interpolation combinations with direct string interpolation. - Adds request-path assertions for create/get QR-code client-engine tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Yoti.Auth/DigitalIdentity/DigitalIdentityService.cs |
Corrects QR-code create and lookup endpoint paths. |
test/Yoti.Auth.Tests/DigitalIdentityClientEngineTests.cs |
Adds URL-path assertions for QR-code requests. |
Comments suppressed due to low confidence (1)
test/Yoti.Auth.Tests/DigitalIdentityClientEngineTests.cs:83
- This URL assertion is weaker than the behavior it is trying to lock down: Contains would still pass if the request path had extra or misplaced path segments around the expected endpoint. Since this test is intended to prevent endpoint-construction regressions, assert the exact AbsolutePath (or at least that it ends with the expected endpoint) so malformed QR-code lookup URLs cannot pass silently.
Assert.IsTrue(_httpRequestMessage.RequestUri.AbsolutePath.Contains($"/v2/qr-codes/{qrCodeId}"));
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .WithBaseUri(apiUrl) | ||
| .WithHeader(yotiAuthId, sdkId) | ||
| .WithEndpoint(string.Format($"/v2/sessions/{0}/qr-codes", sessionId)) | ||
| .WithEndpoint($"/v2/sessions/{sessionId}/qr-codes") |
| Assert.IsNotNull(result); | ||
| Assert.AreEqual(qrCodeId, result.Id); | ||
| Assert.AreEqual(qrCodeUri, result.Uri); | ||
| Assert.IsTrue(_httpRequestMessage.RequestUri.AbsolutePath.Contains($"/v2/sessions/{sessionId}/qr-codes")); |
Replace `string.Format($"/v2/.../{0}", id)` with pure interpolation in
CreateQrCode and GetQrCode endpoints. The original form mixed an
interpolated string with string.Format placeholders, so the {0} was
consumed by the interpolator (rendering the integer literal 0) before
string.Format ran, silently dropping the sessionId / qrCodeId argument.
Every request went to `/v2/sessions/0/qr-codes` or `/v2/qr-codes/0`,
making DigitalIdentityService non-functional since 3.19.0.
Add RequestUri assertions to the two existing tests so this class of
regression can't recur silently.
- CreateQrCode: add Validation.NotNull(sessionId, ...) so a null sessionId throws ArgumentNullException instead of silently building `/v2/sessions//qr-codes`, matching the existing pattern in GetSession and GetQrCode. - DigitalIdentityClientEngineTests: replace AbsolutePath.Contains(...) with AbsolutePath.EndsWith(...) for both QR-code endpoint assertions so misplaced or extra path segments can no longer pass silently.
4d90c2e to
cd8112c
Compare
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.
Summary
Fixes a regression introduced in
3.19.0that madeDigitalIdentityServicecompletely non-functional.CreateQrCodeandGetQrCodebuilt their endpoint URLs withstring.Format($"/v2/.../{0}", id)— mixing an interpolated string ($"...") withstring.Formatplaceholders. The{0}is consumed by the C# interpolator first (rendering the integer literal0), sostring.Formatsees no placeholder and thesessionId/qrCodeIdargument is silently dropped. Every request went to/v2/sessions/0/qr-codesor/v2/qr-codes/0.Replaced with pure interpolation:
$"/v2/sessions/{sessionId}/qr-codes"$"/v2/qr-codes/{qrCodeId}"Also adds
RequestUri.AbsolutePathassertions to the two existing tests inDigitalIdentityClientEngineTestsso the same class of regression can't slip through silently again. (The tests already captured the outgoing request via_httpRequestMessagebut never asserted on the URL.)Related: closes the same bug as external PR #532 (which ships the fix without tests).