fix: wrap third-party resolver error with %w in challenge.go - #15
Merged
Conversation
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.
Closes #2
Summary
Changed the format string for wrapping the third-party client domain resolver error from
%sto%winchallenge.go.What changed
internal/auth/challenge.go, updatedfmt.Errorf("%w: %s: %s", ...)tofmt.Errorf("%w: %s: %w", ...)where the third-party client domain resolver error is returned.Key design decisions
%wis safe because theResolverinterface is provided by the caller/client. Exposing it so they can useerrors.Is(err, TheirCustomError)maintains the proper boundary without leaking internal logic.txnbuildare intentionally kept as they are to avoid leakinggo-stellar-sdkimplementation details to the caller.Acceptance-criteria checklist
fmt.Errorfusages inchallenge.go.%wwhere safe without exposing internal errors to the handler.errors.Is) remains intact.Test output & Coverage result
Follow-ups
read.goandverify.gocould also be systematically reviewed if desired.Security note
Discrepancy note
%s. They were actually already wrapped using%w(e.g.,ErrClientDomainRejected). However, the internal errorerr(which the sentinel wraps) was flattened with%s. We updated this specific format string to%wto preserve theerridentity.