Skip to content

SDK-2806 Fix DigitalIdentityService QR-code URL construction#546

Merged
mehmet-yoti merged 2 commits into
release/3.20.0from
SDK-2806-digital-identity-service-qr-code-path-error
May 15, 2026
Merged

SDK-2806 Fix DigitalIdentityService QR-code URL construction#546
mehmet-yoti merged 2 commits into
release/3.20.0from
SDK-2806-digital-identity-service-qr-code-path-error

Conversation

@mehmet-yoti
Copy link
Copy Markdown
Contributor

@mehmet-yoti mehmet-yoti commented May 15, 2026

Summary

Fixes a regression introduced in 3.19.0 that made DigitalIdentityService completely non-functional.

CreateQrCode and GetQrCode built their endpoint URLs with string.Format($"/v2/.../{0}", id) — mixing an interpolated string ($"...") with string.Format placeholders. The {0} is consumed by the C# interpolator first (rendering the integer literal 0), so string.Format sees no placeholder and the sessionId / qrCodeId argument is silently dropped. Every request went to /v2/sessions/0/qr-codes or /v2/qr-codes/0.

Replaced with pure interpolation:

  • $"/v2/sessions/{sessionId}/qr-codes"
  • $"/v2/qr-codes/{qrCodeId}"

Also adds RequestUri.AbsolutePath assertions to the two existing tests in DigitalIdentityClientEngineTests so the same class of regression can't slip through silently again. (The tests already captured the outgoing request via _httpRequestMessage but never asserted on the URL.)

Related: closes the same bug as external PR #532 (which ships the fix without tests).

@mehmet-yoti mehmet-yoti requested a review from Copilot May 15, 2026 10:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"));
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@mehmet-yoti mehmet-yoti changed the base branch from development to master May 15, 2026 10:41
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.
@mehmet-yoti mehmet-yoti force-pushed the SDK-2806-digital-identity-service-qr-code-path-error branch from 4d90c2e to cd8112c Compare May 15, 2026 10:46
@mehmet-yoti mehmet-yoti requested a review from Copilot May 15, 2026 10:49
@mehmet-yoti mehmet-yoti changed the base branch from master to release/3.20.0 May 15, 2026 10:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@mehmet-yoti mehmet-yoti merged commit c034cb4 into release/3.20.0 May 15, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants