nuts-foundation / nuts-foundation/nuts-node
OpenID4VCI client: improve HTTP debuggability (TestResponseCodeWithLog + OTEL spans)
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 28
- Forks
- 23
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 76
Description
As part of the v1.0 refactor (#3953), tighten up the OpenID4VCI HTTP client (vcr/openid4vci/issuer_client.go, wallet_client.go) so failures are easier to diagnose in production.
Goals
- Use
core.TestResponseCodeWithLogfor response-status checking instead of the local truncate-and-log block inhttpDo. This gives us the standard clipped body log on unexpected statuses and the typedcore.HttpError(withStatusCode/ResponseBody) that callers can inspect. - Make the HTTP client emit OTEL spans for every OpenID4VCI request. The underlying
http/clientalready wraps its transport withotelhttp.NewTransportwhen tracing is enabled, buthttpOAuth2Client.RequestAccessTokencurrently callshttp.NewRequestWithContext(context.Background(), ...), which severs the parent span. The result is that OAuth2 token requests appear as orphan spans (or are missing entirely) in traces of a credential-issuance flow.
Scope
- Plumb
context.ContextthroughOAuth2Client.RequestAccessToken(interface change; cascade throughdefaultIssuerAPIClient, mocks, and the caller invcr/holder/openid.go:HandleCredentialOffer). - Replace the manual body-clipping/log in
httpDowithcore.TestResponseCodeWithLog. - Preserve the existing 2xx-range semantics.
TestResponseCodeWithLogdoes an exact-match on the status code, so a naive swap silently rejects legitimate 201/202/204 responses. Per OpenID4VCI v1.0, deferred credential issuance returns 202 and the credential-offer endpoint typically uses 204, so the call sites need to declare the expected status code(s) (e.g. extendhttpDoto take anexpectedStatus int, or add acore.TestResponseCode2xx*helper). Decide on the shape during the v1.0 refactor. - Drop the dead
var HttpClientTrace *httptrace.ClientTrace = nilglobal — it is exported but never assigned.
Why now
Defer to the v1.0 refactor so the status-code semantics question is settled in one pass alongside deferred-issuance support, instead of being shoehorned into an interim PR.
Out of scope
- Adding explicit OpenID4VCI-level spans on top of the
otelhttptransport spans — the transport-level spans are sufficient once context propagation is fixed.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with vcr/openid4vci/issuer_client.go and wallet_client.go, then trace OAuth2Client.RequestAccessToken through defaultIssuerAPIClient, mocks, and vcr/holder/openid.go:HandleCredentialOffer. Review httpDo and core.TestResponseCodeWithLog first. Done means context reaches token requests, all valid 2xx responses remain accepted, failures expose the typed error, OTEL transport spans are connected, and HttpClientTrace is removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, observability-sre
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100