Skip to content

Pass context into loadWebAuthnCredentials to preserve trace ID in warn logs#25

Merged
veverkap merged 2 commits into
mainfrom
copilot/add-context-to-load-webauthn-credentials
Apr 17, 2026
Merged

Pass context into loadWebAuthnCredentials to preserve trace ID in warn logs#25
veverkap merged 2 commits into
mainfrom
copilot/add-context-to-load-webauthn-credentials

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

loadWebAuthnCredentials used slog.Warn without a context, silently dropping the request's trace ID and any context-propagated fields from the "skipping corrupted passkey credential" log line.

Changes

  • handler/passkey.go — Added ctx context.Context as first parameter to loadWebAuthnCredentials; swapped slog.Warnslog.WarnContext(ctx, ...)
  • Call sites — Updated BeginRegistration, FinishRegistration, and FinishAuthentication (including the inner DiscoverableUserHandler closure) to pass r.Context()
  • handler/passkey_test.go — Updated two unit-test call sites to pass context.Background()
// before
func loadWebAuthnCredentials(creds []auth.PasskeyCredential) []webauthn.Credential {
    ...
    slog.Warn("skipping corrupted passkey credential", slog.String("id", creds[i].ID))

// after
func loadWebAuthnCredentials(ctx context.Context, creds []auth.PasskeyCredential) []webauthn.Credential {
    ...
    slog.WarnContext(ctx, "skipping corrupted passkey credential", slog.String("id", creds[i].ID))

…o-load-webauthn-credentials

Resolve conflict in handler/passkey_test.go by keeping ctx parameter in
loadWebAuthnCredentials call while adopting the improved test name from main.
@veverkap veverkap marked this pull request as ready for review April 17, 2026 17:20
@veverkap veverkap requested review from a team and Copilot April 17, 2026 17:20
Copy link
Copy Markdown
Contributor

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

This PR preserves request-scoped logging fields (e.g., trace IDs) for the “skipping corrupted passkey credential” warning by threading context.Context into the loadWebAuthnCredentials helper and switching to slog.WarnContext.

Changes:

  • Updated loadWebAuthnCredentials signature to accept ctx context.Context and replaced slog.Warn with slog.WarnContext.
  • Updated handler call sites (including the discoverable user handler closure) to pass r.Context().
  • Updated unit tests to pass context.Background() at the two direct call sites.
Show a summary per file
File Description
handler/passkey.go Propagates request context into the helper and uses context-aware warning logging to preserve trace/context fields.
handler/passkey_test.go Adjusts tests for the new helper signature by providing a context.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@veverkap veverkap merged commit 8fdcf64 into main Apr 17, 2026
10 checks passed
@veverkap veverkap deleted the copilot/add-context-to-load-webauthn-credentials branch April 17, 2026 17:30
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.

3 participants